You are here

Code getting stuck at sprintf | Cypress Semiconductor

Code getting stuck at sprintf

Summary: 1 Reply, Latest post by Bob Marlowe on 08 Mar 2016 11:20 PM PST
Verified Answers: 1
Last post
Log in to post new comments.
CYang's picture
14 posts

For some reason this code gets stuck at sprintf in debug mode. Any tips? 

#include <project.h>
#include <stdio.h>

int main()
    CyGlobalIntEnable; /* Enable global interrupts. */
    char* str;
    sprintf(str, "Hello");


user_1377889's picture
9268 posts

Set heap size to 0x0200 (in cydwr System), set use newlib nano (build settings Linker)and allow for float formatting.

You defined str to be a pointer to char, but you did not allocate any memory for your string.

Better define

char str[80];   //  Maximum line length




Log in to post new comments.