This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/16492] sprintf


------- Additional Comments From aotto1968 at onlinehome dot de  2004-07-12 14:32 -------
Hi, 
 
  the answer does not satisfy me, why ? 
 1. assume I have 10 bytes space not 11 
    the >char str[11]< 11'th char is just for displaying in the example 
    if I rewrite to > snprintf(str, 11, "%10p", 0x12345678); 
    the 11'th char was changed to \0 -> not allowed 
    if I rewrite to > snprintf(str, 10, "%11p", 0x12345678); 
     this does not help to 
 2. expand example: 
#include <stdio.h> 
 
int main (void) 
{ 
    char str[12]; 
    str[11] = '*';  // do not overwrite that beast 
    str[12] = '\0'; // end of string 
    snprintf(str, 10, "%10p", 0x12345678); 
// now I expect "0x12345678*" 
    printf("%s\n", str); 
} 
 
if possible for you, you can change upper code to something 
 >> exactly writing << an 10 byte ascii pointer to the string 
 without overwriting the boader's 
 
thanks 
 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16492


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]