- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
using this line of code
strcpy(output_buffer+output_counter,"Hello World\r\n");
output_counter += 15;
output_counter += sprintf(output_buffer+output_counter, "%d\r\n", 60);
I should get an output of "Hello World\r\n60\r\n" but instead im getting an output of "Hello World\r\n15536"
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if I make it
strcpy(output_buffer+output_counter,"Hello World\r\n");
output_counter += 15;
output_counter += sprintf(output_buffer+output_counter, "%d\r\n", 100);
I get "Hello World\r\n25776\r\n"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if I change the value to a long I get the correct output, ie
strcpy(output_buffer+output_counter,"Hello World\r\n");
output_counter += 15;
output_counter += sprintf(output_buffer+output_counter, "%ld\r\n", 100l);
I get "Hello World\r\n100\r\n"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The numbers 60 and 100 can and will be represented by an uint8, while the %d format expects an integer. All will go well when you use 60u and 100u.
Bob