Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/23/04 10:18
Read: times


 
#74736 - RE: What do you doubt?
Responding to: ???'s previous message
"If you meant "If the format string contains a '%'" then there is nothing wrong with it: format string contains `%` often and often."

char buff[10];
char source[]="%frog";

//This copies the string ok:
sprintf(buff,"%s",source);

//This attempts to use a non-existent floating
//point argument:
sprintf(buff,source);

In the second example the source string is treated as the format string meaning that it's contents are significant to sprintf(). So, if the source string contains a '%' character you would probably have a corrupt stack on an average PC 'C' implementation and at minimum unexpected behaviour on an 8051 'C' implementation.

List of 19 messages in thread
TopicAuthorDate
doub about strutc pointers            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
      What do you doubt?            01/01/70 00:00      
         RE: What do you doubt?            01/01/70 00:00      
            RE: What do you doubt?            01/01/70 00:00      
            RE: What do you doubt?            01/01/70 00:00      
               RE: What do you doubt?            01/01/70 00:00      
                  RE: What do you doubt?            01/01/70 00:00      
                  RE: What do you doubt?            01/01/70 00:00      
                     RE: What do you doubt?            01/01/70 00:00      
            RE: undefined behaviour land            01/01/70 00:00      
         RE: What do you doubt?            01/01/70 00:00      
         Still unknown doubt            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
      Nothing 8051-specific here            01/01/70 00:00      
         RE: Nothing 8051-specific here            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      
   RE: doub about strutc pointers            01/01/70 00:00      

Back to Subject List