I am trying to put characters into an array.
I placed the following in a file called "ultranew.DAT", character by character (with a white space at the end):
C078C75D.DAT
I open the file "ultranew.DAT" and a destination file called "ultranew2.DAT" with the following code:
instream2.open("ultranew.DAT");
outstream2.open("ultranewtwo.DAT", ios::app);
My plan is to get the characters from the file "ultranew.DAT", put them into an array, and print the array to the file "ultranewtwo.DAT"
I try to place "C078C75D.DAT" into an array called "mystring", character by character with the following code:
char next;
char mystring[12];
while (index<12)
{
if (mystring[index] != ' ')
{
instream2.get(next);
outstream2<<next;
mystring[index]=next;
index++;
}
}
However, when I print out the array, it has "no" at the end, and regardless of how large I make the array, "no" always appears at the end. I know that the "no" comes from this part of my code earlier in the program:
char yes[4], no[3];
strcpy(yes, "yes");
strcpy(no, "no");
This is totally unrelated to the array "mystring", so I have no idea how "no" appears at the end of the array. Does anyone know what's going on and/or how I can fix this? Thank you very much for any help!
I placed the following in a file called "ultranew.DAT", character by character (with a white space at the end):
C078C75D.DAT
I open the file "ultranew.DAT" and a destination file called "ultranew2.DAT" with the following code:
instream2.open("ultranew.DAT");
outstream2.open("ultranewtwo.DAT", ios::app);
My plan is to get the characters from the file "ultranew.DAT", put them into an array, and print the array to the file "ultranewtwo.DAT"
I try to place "C078C75D.DAT" into an array called "mystring", character by character with the following code:
char next;
char mystring[12];
while (index<12)
{
if (mystring[index] != ' ')
{
instream2.get(next);
outstream2<<next;
mystring[index]=next;
index++;
}
}
However, when I print out the array, it has "no" at the end, and regardless of how large I make the array, "no" always appears at the end. I know that the "no" comes from this part of my code earlier in the program:
char yes[4], no[3];
strcpy(yes, "yes");
strcpy(no, "no");
This is totally unrelated to the array "mystring", so I have no idea how "no" appears at the end of the array. Does anyone know what's going on and/or how I can fix this? Thank you very much for any help!