B
Bert
Hi, I'm unhappy: why doesn't this work?
char enc[10000];
char temp[70];
for(int i=0;i<10000;i++){
fscanf(in,"%s",&temp);
if(temp[0]=='#')break;
else
for(int j=0;j<70;j++)
if(temp[j]!='\0')
enc=temp[j];
else break;
}
The input is from a text file (.txt) that contains an encrypted
message between 1 and 10 000 letters long that may be split across
several lines in the input file; each line will contain between 1 and
70 letters inclusive and the final line will contain one #. I want the
entire message to be stored in enc (excluding the #). I thought I'm
using temp to store one line of text, checking if the first character
is a # and if not storing those characters into the next available
slots in the array enc until enc is filled up.
I'm unhappy
Bert
char enc[10000];
char temp[70];
for(int i=0;i<10000;i++){
fscanf(in,"%s",&temp);
if(temp[0]=='#')break;
else
for(int j=0;j<70;j++)
if(temp[j]!='\0')
enc=temp[j];
else break;
}
The input is from a text file (.txt) that contains an encrypted
message between 1 and 10 000 letters long that may be split across
several lines in the input file; each line will contain between 1 and
70 letters inclusive and the final line will contain one #. I want the
entire message to be stored in enc (excluding the #). I thought I'm
using temp to store one line of text, checking if the first character
is a # and if not storing those characters into the next available
slots in the array enc until enc is filled up.
I'm unhappy
Bert