Results 1 to 5 of 5

Thread: Problem with C++ Language

  1. #1
    Join Date
    Jan 2009
    Posts
    85

    Problem with C++ Language

    I am going through a hectic error in c++ language. I am having some critical errors and problems writing a simple program. The only errors I am getting is "undeclared identifier", but the variable is declared and initialized through user input before it is using it

    Please help me with this problem

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Problem with C++ Language

    Example

    doy.cpp: In function `int main()':
    doy.cpp:25: `DayOfYear' undeclared (first use this function)
    doy.cpp:25: (Each undeclared identifier is reported only once for each function
    it appears in.)
    doy.cpp:25: parse error before `;' token
    Meaning
    You used "DayOfYear" in your code, but the compiler has not seen a definition for "DayOfYear". It doesn't know what "DayOfYear" is.
    Usual Causes
    You forgot to include the header file that defines the class/struct/function/etc
    You misspelled the name of the identifier

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Problem with C++ Language

    You cannot nest functions and subroutines in C. Thus, you cannot put the code for Startstr() within main(). You need to do this:
    Code:
    char *Startstr(char * s, char * sub); // Function prototype
    int main() {
    .. code for main ..
    }

    char *Startstr(char * s, char * sub) {
    .. code for Startstr
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Problem with C++ Language

    You need to declare s and sub within main(). This is the cause of your error.
    Code:
    int main() {
    char s[50], sub[50];
    .. rest of code
    }

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Problem with C++ Language

    You're using the strstr() function. You need to #include <cstring> instead of <string>. Also, you need to declare that you're using the standard namespace:
    Code:
    #include <iostream>
    #include <cstring>

    using namespace std;

    If you don't have that using statement, you will need to qualify all your objects/functions like this:
    std::cout << "...";
    std::cin >> "....";

Similar Threads

  1. Cod black ops Language Problem
    By dubul in forum Video Games
    Replies: 3
    Last Post: 17-11-2010, 12:51 AM
  2. IE7 and MUI Language problem
    By ALEXANDRO in forum Windows Software
    Replies: 3
    Last Post: 16-10-2009, 04:49 PM
  3. Problem with Multithreading in C Language
    By Jagdish Gada in forum Software Development
    Replies: 4
    Last Post: 09-03-2009, 02:10 PM
  4. Problem regarding PHP Programming Language
    By NetWorm in forum Software Development
    Replies: 3
    Last Post: 02-03-2009, 03:04 PM
  5. F1 2002 pc language problem
    By Muhammad Waqar in forum Video Games
    Replies: 1
    Last Post: 21-11-2008, 07:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,853,569.37729 seconds with 16 queries