But how come i cannot declare String??
There's an error: Undeclared identifier "string"
i have already included string.h
#include <iostream>
#include <fstream.h>
#include <stdlib.h>
#include <STRING>
int main () {
String A;
return 0;
}
Printable View
But how come i cannot declare String??
There's an error: Undeclared identifier "string"
i have already included string.h
#include <iostream>
#include <fstream.h>
#include <stdlib.h>
#include <STRING>
int main () {
String A;
return 0;
}
This is a C# forum, not a C++ one.
But it probably has something to do with the case.
Try
string instead of String
it doesnt solve the problem
Thanks
No you haven't. including <string> does NOT guarentee that string.h is included. #include <string>, however, is the correct way.Quote:
Originally posted by Shaman
i have already included string.h
Are you coming from VB? DO NOT USE CAPITALS!!!, C++ is case sensative in everything. An INT is not the same as an int.Quote:
Originally posted by Shaman
Code:#include <iostream>
#include <fstream.h>
#include <stdlib.h>
#include <STRING>
int main () {
String A;
return 0;
}
To include and use a string:
Also, why do you have these in your code?:Code:#include <iostream>
#include <string>
int main () {
string A;
}
You declare the first header (iostream) correctly, these 2 deprecately and the last 1 incorrectly (capitals).Code:#include <fstream.h>
#include <stdlib.h>
If you want fstream and stdlib, do this:
Also, there is a C++ forum here, post C++ questions there. C# is an entirely different language with similar syntax in certain elements.Code:#include <fstream>
#include <cstdlib>
i have found the solution
declaration is :
#include <string.h>
using namespace std;
Its a stupid MS bug!
Thanks
Its not a bug. My guess is you are using Managed C++, so you have to use the managed extensions.
No, that is a bad solution because that is a deprecate header file. Include <string> not <string.h>.Quote:
Originally posted by Shaman
i have found the solution
declaration is :
#include <string.h>
using namespace std;
Its a stupid MS bug!
Thanks
Because the header is deprecate, it doesn't even use the namespace std, so why did you even declare it?
That isn't an MS bug, I'd suggest a nice C++ book that is caught up with the standard. www.nuwen.net click on C++, go to the bottom and check out the book recommendations. They are all great.
Managed extensions don't mean you use string.h instead of string. string.h is deprecate, he should be using <string>.Quote:
Originally posted by DevGrp
Its not a bug. My guess is you are using Managed C++, so you have to use the managed extensions.
I was'nt refering to the <string> or <string.h>. I was refering to the using namespace std which is used when writing managed C++.Quote:
Originally posted by kasracer
No, that is a bad solution because that is a deprecate header file. Include <string> not <string.h>.
Because the header is deprecate, it doesn't even use the namespace std, so why did you even declare it?
That isn't an MS bug, I'd suggest a nice C++ book that is caught up with the standard. www.nuwen.net click on C++, go to the bottom and check out the book recommendations. They are all great.
Managed extensions don't mean you use string.h instead of string. string.h is deprecate, he should be using <string>.
Uh, no. Managed C++ uses Microsoft's Propritary .NET framework.Quote:
Originally posted by DevGrp
I was'nt refering to the <string> or <string.h>. I was refering to the using namespace std which is used when writing managed C++.
The using namespace directive just states that he will be using the namespace std, which is part of the standard C++ libraries.
std has NOTHING to do with managed C++.