|
-
Oct 7th, 2002, 03:05 AM
#1
Thread Starter
Lively Member
eVC++ String manipulation **RESOLVED**
Hi there,
i am hoping someone can help me, i am writing a proggy in eVC++ the problem i have is i am trying to manipulate an array of character. i am setting the value of the array to NULL and then reading in the values from a file (17 characters at a time, though this causes problems and i find that 18 characters which includes the CR/LF characters on the end of the line) and placing the data from the file into the array.
then i want to append a few more characters on the end of this string. the problem i have, is that even though i initialise the array (as far as i know) the last few characters that appear in the array before it is re-initialised remain there and the characters i appent to the string get lost when i write the string to another file.
Below is a copy of the code i have:
void CNewForm::OnbtnComplete()
{int numread, numwritten;
char pList[21];
char NewVal[]="ZX";
(stream2 = fopen("\\temp\\sequence.txt","r+"));
//switch data between files. prove it can be done.
while (!feof(stream2))
{
pList[0]=NULL;
numread = fread( pList, sizeof( char ), 18 , stream2 );
strncat(pList,NewVal,2);
numwritten=fwrite(pList, sizeof(char), 21, stream);
}
fclose(stream);
fclose(stream2);
CDialog::OnOK();
}
note: Stream is opened earlier in the program as a w+ or a+ format depending on whether the file exists or not.
Please help me!
R
Last edited by rabhen; Oct 7th, 2002 at 09:21 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|