fprintf not completing

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

fprintf not completing

1,443 次查看
bapoo1
Contributor I

Hi all, 

I have been trying to simply write some data to a file using the semihost and corresponding redlib libraries. Below is the code I am using - I can create the file in the correct directory, however, it just stalls when it gets to fprintf. I've read a few posts here saying that the issue is normally not using the semihost-compatible C libraries, but I've made this fix and cannot get the fprintf function to work. Can someone please help? 

//

FILE *fp = fopen("C:\\Users\\BApoo\\Desktop\\Test.txt","w");

if(fp == NULL)
{
printf("Error opening file!\n");
exit(1);
}

const char *text = "This is a string which is written to a file.";

fprintf(fp, "%s\n", text);
fflush(fp);
fclose(fp);

//

0 项奖励
回复
2 回复数

1,436 次查看
converse
Senior Contributor V

Works here.

Which MCU are you using and which debug probe?

0 项奖励
回复

1,428 次查看
bapoo1
Contributor I

Thank you for your prompt response.

I am using the QN9080SIP with a SEGGER J-link probe. If it is of any use, I am using a Keil ULINK 2 Debug Adapter to talk with the MCU over SWD. 

0 项奖励
回复