Hi,
I just wanted a little clarification. I have run across this in my books:
#include <string.h>
string my_str;
So, is there a difference from that and...
CString my_str;
I figure that "CString" is a class of sorts, I know "char" is a type so what is "string"? A different class or the same as CString? And, what header would I need to include to used the CString?
One other thing if I may. I have been using a while loop similar to this to read input records from a file...
while (getline(infp,buffer))
{
sscanf(buffer.c_str(),"%u %s %s %s %d %u %s", &Key, Year, Month, Day, Code, Week , Zone)
---processing statements...
}
Obviously, sscanf() works fine using C, but with C++ there must be a better way. One problem I have is with reading Zone. It is a C style char string but when I try to make it:
string Zone;
It bombs with sscanf(). I'm not sure why but I'd rather use more C++ like conventions (still keeping it simple though). Any suggestions?
Thanks for the help.
I just wanted a little clarification. I have run across this in my books:
#include <string.h>
string my_str;
So, is there a difference from that and...
CString my_str;
I figure that "CString" is a class of sorts, I know "char" is a type so what is "string"? A different class or the same as CString? And, what header would I need to include to used the CString?
One other thing if I may. I have been using a while loop similar to this to read input records from a file...
while (getline(infp,buffer))
{
sscanf(buffer.c_str(),"%u %s %s %s %d %u %s", &Key, Year, Month, Day, Code, Week , Zone)
---processing statements...
}
Obviously, sscanf() works fine using C, but with C++ there must be a better way. One problem I have is with reading Zone. It is a C style char string but when I try to make it:
string Zone;
It bombs with sscanf(). I'm not sure why but I'd rather use more C++ like conventions (still keeping it simple though). Any suggestions?
Thanks for the help.