Menu

Flushing the contents of a char var

2002-12-04
2012-09-26
  • Nobody/Anonymous

    Simple question, how can i make myself sure that a "char something[somesize];, declared in its own block of {} will have its content totally flushed betweens calls for the functions? Heres what im talking about:

    int SomeFunction(char TheParam) {
      char ThatString[150];
     
      sprintf(ThatString, "", 0); /I need to be sure that all the times this functions is called, ThatString = 0.
      strcat(ThatString, TheParam);
     
      SendMessage(hWndSomeControl, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) ThatString);       
      sprintf(ThatString, "", 0); //Clearing the string, is there any other way to do it?
      sprintf(TheParam, "", 0); //Clearing the string, is there any other way to do it?
     
      return 0;
    }

     
    • Anonymous

      Anonymous - 2002-12-05

      declare as char ThatString[150] ="";

       
    • Nobody/Anonymous

      Nope, didnt do it. Doint it like you said, weird  characters start  to accumulate in the beginning of the string every time the Message is sent to the Control.

      And with the sprintf(ThatString, "", 0); that does not happens :\

      It sux :\ I have no problem with using this sprintf thing, but it gives me lots of gcc warnings...

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.