hello.c
来自「介绍DSP通过USB与主机的数据传送代码」· C语言 代码 · 共 34 行
C
34 行
#include <stdio.h>
#include "hello.h"
#define BUFSIZE 30
struct PARMS str = { 2934, 9432, 213, 9432, &str };
/* * ======== main ======== */
void main()
{ #ifdef FILEIO int i;
char scanStr[ BUFSIZE];
char fileStr[ BUFSIZE];
size_t readSize;
FILE *fptr;
#endif
/* write a string to stdout */
puts("hello world!\ n");
#ifdef FILEIO
/* clear char arrays */
for (i = 0; i < BUFSIZE; i++)
{ scanStr[ i] = 0
/* deliberate syntax error */
fileStr[ i] = 0; }
/* read a string from stdin */
scanf("%s", scanStr);
/* open a file on the host and write char array */
fptr = fopen("file.txt", "w");
fprintf(fptr, "%s", scanStr);
fclose(fptr);
/* open a file on the host and read char array */
fptr = fopen("file.txt", "r");
fseek(fptr, 0L, SEEK_SET);
readSize = fread(fileStr, sizeof(char), BUFSIZE, fptr);
printf("Read a %d byte char array: %s \n", readSize, fileStr);
fclose(fptr);
#endif }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?