![]() |
|
#1
|
|||
|
|||
sprintf and snprintf question in CHi,
My C library doesn't have the snprintf function built in. I would like to know how to change the following code from snprintf to sprintf. int len =strlen(book->name); snprintf(book->name + len, sizeof(book->name) -len -1, "%s", book->id); Any help would be appreciated. rn2388 |
|||
|
#2
|
||||
|
||||
|
Quote:
Hello rn2388. Welcome to GIDForums. You should be able to replicate this using a quick strcpy and a properly placed null. CPP / C++ / C Code:
That being said, I am lost in what this is doing. I see no instance in which sizeof(book->name) - len -1 is going to result in a positive number. What am I missing? |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The