Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6581733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:11:27+00:00 2026-05-25T16:11:27+00:00

I am creating a texteditor in c++[non gui] , So far i have ended

  • 0

I am creating a texteditor in c++[non gui] , So far i have ended up with this code..
i get two undeclared errors… Why?

#include <iostream>
#include <fstream>

using namespace std;


int main()
{
    int op;
    cout<<"do you want to open example.txt or overwrite?\nIf you want to overwrite enter 1 , if you want to view it enter 2. :\n";
    cin>>op;
    if(op==1)
    {
        edit();
    }
    else if(op==2)
    {
        open();
    }
}

void edit()
{
    int op;
    string x;
    ofstream a_file("example.txt" , ios::app);
    cout<<"HEY ENTER SOME TEXT TO BE WRITTEN TO EXAMPLE.txt [created by rohan bojja]\n--------------------------------------------------------------------------------\n";
    getline ( cin , x);
    a_file<<x;
    cout<<"want to type in an other line?\n1 for YES, 2 for NO";
    cin>>op;
   while(op==1)
   {
       a_file<<"\n";
       edit;
   }
   cout<<"Do you want to quit?\n1 for YES , 2 for NO";
    cin>>op;
    if (op==2)
    {
    edit;
    }
}
void open()
{
    int op;
    ifstream a_file("example.txt");
    cout<<"You are now viewing example.txt [created by rohan bojja]\n--------------------------------------------------------------------------------\n";
    cout<<a_file;
    cout<<"Do you want to quit?\n1 for YES , 2 for NO";
    cin>>op;
   if(op==2)
    {
        open;
    }
}

but , while compiling i get the error [CodeBlocks Build Log]:

F:\Projects\c++\TextEditor\texteditor.cpp: In function 'int main()':
F:\Projects\c++\TextEditor\texteditor.cpp:14: error: 'edit' was not declared in this scope
F:\Projects\c++\TextEditor\texteditor.cpp:18: error: 'open' was not declared in this scope
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:11:28+00:00Added an answer on May 25, 2026 at 4:11 pm

    Your main function can’t see the edit and open functions because they appears after main. You can fix this by either:

    1) Moving the edit and open functions above main; or

    2) Adding a prototype of edit and open above main. Add this line of code before main, but after using namespace std:

    void edit();
    void open();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a voting system just like stackoverflow. Questions like this have been asking several
Creating hashes of hashes in Ruby allows for convenient two (or more) dimensional lookups.
Creating Traversals for Binary Search Tree with Recursion. void inOrder(void (*inOrderPtr)(T&)) { if(this->left !=
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
When creating a web application, and lets say you have a User object denoting
I'm creating a rich text editor. Basically I have an iframe with design mode
I am creating some html from code running on a WinForm. I want to
Hello I hope this is my last post concerning sql connectionsstrings.... I have a
Creating this ajax styled wordpress portfolio theme and I'm a little stuck on how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.