Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 09-03-2009
Member
 
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
Reply With Quote
  #2  
Old 09-03-2009
Member
 
Join Date: May 2008
Posts: 2,293
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
Reply With Quote
  #3  
Old 09-03-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
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
}
Reply With Quote
  #4  
Old 09-03-2009
Member
 
Join Date: May 2008
Posts: 2,383
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
}
Reply With Quote
  #5  
Old 09-03-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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 >> "....";
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 08:39 PM.