Hai,

i had tried to write a string which is fetched from a database into a file....

Here are my codings to write that fetched string into a text file...

Code:
HANDLE hFile;
DWORD wmWritten;
hFile =CreateFile("D:\\test.text",GENERIC_READ|GENERIC_WRITE,  FILE_SHARE_READ,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

while (( row = mysql_fetch_row(res_set)) != NULL)
{

       char str[100];
       char *tmp = str;
       strcpy(str, row[2]);

       //For writing a file
       WriteFile(hFile,str,(DWORD)(sizeof(str)),&wmWritten,NULL);
       CloseHandle(hFile);
 }
           mysql_close(conn);
 }
Here row[2] contains a string "senthil"..... when i run the above program

the string "senthil" easily fetched from the database and write into the text

file perfectly... But there are some special garbage characters

like "€'éEY|Ðþ™ž6àþ’@Ðþp@ËÅ å Cí~/ÇÀÿ"

which are also automatically writing into the file....

This is bcoz the "senthil" contains only 7 characters.... but the str array size
is str[100]...

so the remaining space are filled up by these garbage characters and

writing into the file...

so i want to add a null character into string to stop fetching these garbage
characters...

By which method shall i use the null character to stop fetching the garabage
characters....

i'm a beginner to c++...

so any one can help me..