91学习

陪伴你每一天!

calloc函数的用法

#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char *ch; ch=(char*)calloc(30,sizeof(char)); strcpy(ch,"ILOVEYOU"); printf("%s\n",ch); free(ch); return 0;}

有多少件衣服

#include <stdio.h>#include <stdlib.h>int main(){ int *iIntMalloc=(int*)malloc(sizeof(int)); *iIntMalloc=10240; printf("衣服有%d件\n",*iIntMalloc); return 0;}

栈的使用

#include <stdio.h>#include <stdlib.h>void DisplayB(char* string){ printf("%s\n",string);}void DisplayA(char*string){ char String[20]="LoverWorld!"; printf("%s\n",string); DisplayB(String);}int main(){ char St

在堆中分配一个char型指针

#include <stdio.h>#include <stdlib.h>int main(){ char *pInt; pInt=(char*)malloc(sizeof(char)); *pInt=65; printf("the graph is:%c\n",*pInt); free(pInt); return 0;}

将两个文件内容输入到同一个文件中

#include <stdio.h>#include <process.h>void main(){ FILE *fp1,*fp2; char ch,filename1[30],filename2[30]; printf("请输入文件名1:\n"); scanf("%s",filename1); printf("请输入文件名2:\n"); scanf("%s",filename2); if((

ftell()函数模拟设置银行卡号

#include <stdio.h>#include <process.h>int main(){ int n; FILE *fp; char ch,str[30],filename[30]; printf("please input the filename:\n"); scanf("%s",filename); if((fp=fopen(filename,"w"))==NULL){ printf("

rewind()函数输出两遍

#include <stdio.h>#include <process.h>void main(){ FILE *fp; char ch,filename[30]; printf("please input filename:\n"); scanf("%s",filename); if((fp=fopen(filename,"r"))==NULL){ printf("can not open file

fseek()定位文件来获取部分内容

#include <stdio.h>#include <process.h>void main(){ FILE *fp; char filename[30],str[50]; printf("please input the filename:\n"); scanf("%s",filename); if((fp=fopen(filename,"wb"))==NULL){ printf("can not

fscanf()函数读取fp所指向的文件中的i的值

#include <stdio.h>#include <process.h>void main(){ FILE *fp; char i,j; char filename[30]; printf("please input the filename:\n"); scanf("%s",filename); while((fp=fopen(filename,"r"))==NULL){ printf("can

fprintf()函数将变量以某种形式输入到fp指向的文件中去

#include <stdio.h>#include <process.h>void main(){ FILE *fp; int i=88; char filename[30]; printf("please input filename:\n"); scanf("%s",filename); if((fp=fopen(filename,"w"))==NULL){ printf("can not op