LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   C++ problem , string.h not functioning properly (https://www.linuxquestions.org/questions/programming-9/c-problem-string-h-not-functioning-properly-45955/)

cyberswami 02-18-2003 05:11 AM

C++ problem , string.h not functioning properly
 
Supposing i have a sample problem as follows :-
#include <string.h>
#include <iostream>
int main()
{
string test;
test= "this is a test";
cout<<name;
return 0;
}
and save it as test.cc

on compiling it the following error occurs :--
test.cc: In function `int main()':
test.cc:5: `string' undeclared (first use this function)
test.cc:5: (Each undeclared identifier is reported only once for each function
it appears in.)
test.cc:5: parse error before `;' token
test.cc:6: `name' undeclared (first use this function)
test.cc:7: `cout' undeclared (first use this function)

but the string.h file is in the /usr/share directory

what could be the problem
pls help

Palin 02-18-2003 10:05 AM

use <string> instead of <string.h> you will probably need to add some stuff

like std::cout I believe

finidi 02-18-2003 10:16 AM

using namespace std;

cyberswami 02-18-2003 10:34 PM

thanx man, it worked

moeminhtun 02-18-2003 11:20 PM

This thread would be helpful.

http://www.linuxquestions.org/questi...threadid=43963


All times are GMT -5. The time now is 04:24 PM.