简体   繁体   中英

How to flush string which is in structure?

My structure:

struct Data{
   char buffer[MAX_BUFF];
   int bufferPos;
};

How I execute function searchFile :

searchFile(outFile, logFile, category, keyword, srcName, &dat);

In function searchFile I would like to do something like fflush(dat->buffer) . Unfortunately, this gives me an error. I also tried str(dat->buffer, "") and dat->buffer[0] = '\\0' , but this does not seem to clear out my string dat.buffer . Any ideas?

Full code: http://pastebin.com/aHWPLqPx

Assuming that you want to remove any meaningful data from the buffer, you would overwrite the whole thing with zeros and reset bufferPos .

Something like

memset(dat->buffer,0,MAX_BUFF);
dat->bufferPos=0;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM