S
snow.carriers
Let me first state that I'm using Borland Turbo C++, it's relatively
old so the new string methods won't work. Anyways, first I'm trying to
collect a line of a string (with numbers, letters, dashes) into each
variable. For just numbers, it's relatively easy:
ifstream fout("s1.in");
for (a=0; a<17; a++) {
fout >> data[a];
cout << data[a] << endl;
}
Where a and data[17] are just regular integers. However, when I change
variable c to char[11] (since it has letters, and each line only needs
to hold 11, no more), and when I change data[a] to a char, I get these
two errors:
L value required in function xxx
Cannot convert 'int' to 'char *' in function xxx
I was wondering what would be the best fix for this. In addition, how
would string addition occur? In Java, it's relatively simple:
String out;
out = "";
out = out + "1"; ...etc
But in C++ I'm having a hard time. For string, I'm using char out[12].
When I assign out[12] = "", it won't work, I get an error. Same with
string addition, when I use out[12] = out[12] "1", it still doesn't
work. I've searched google and can't seem to find much information on
it.
If anyone can help me out, I'd appreciate it. Thanks.
old so the new string methods won't work. Anyways, first I'm trying to
collect a line of a string (with numbers, letters, dashes) into each
variable. For just numbers, it's relatively easy:
ifstream fout("s1.in");
for (a=0; a<17; a++) {
fout >> data[a];
cout << data[a] << endl;
}
Where a and data[17] are just regular integers. However, when I change
variable c to char[11] (since it has letters, and each line only needs
to hold 11, no more), and when I change data[a] to a char, I get these
two errors:
L value required in function xxx
Cannot convert 'int' to 'char *' in function xxx
I was wondering what would be the best fix for this. In addition, how
would string addition occur? In Java, it's relatively simple:
String out;
out = "";
out = out + "1"; ...etc
But in C++ I'm having a hard time. For string, I'm using char out[12].
When I assign out[12] = "", it won't work, I get an error. Same with
string addition, when I use out[12] = out[12] "1", it still doesn't
work. I've searched google and can't seem to find much information on
it.
If anyone can help me out, I'd appreciate it. Thanks.