这个生成梯形波的c程序
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <math.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- uint8_t data[32]={32,64,96,128, 160,192,224,0xff, 0xff,0xff,0xff,0xff, 0xff,224,192,160, 128,96,64,32, 0,0,0,0, 0,0,0,0, 0,0,0,0};
- int main(int argc, char *argv[]) {
- FILE *fp;
- uint32_t i;
- if((fp=fopen("123.txt","wb+"))==NULL)
- printf("file cannot open \n");
- else
- printf("file opened for writing \n");
-
- for(i=0;i<=255;i++)
- {
- fputc(data[i%32],fp);
- }
- if(fclose(fp)!=0)
- printf("file cannot be closed \n");
- else
- printf("file is now closed \n");
- return 0;
- }
|