大家好,今天小编关注到一个比较有意思的话题,就是关于c语言写一的问题,于是小编就整理了3个相关介绍c语言写一的解答,让我们一起看看吧。
用C语言编写程序:输入一个字符?
#include<stdio.h>#include<string.h>void main(){ char ch[40],ch2[20],ch3[20],i,j,temp,x; printf("请输入第一串字符:"); gets(ch); printf("请输入第二串字符:"); gets(ch2); printf("请输入插入的:"); scanf("%d",&i); temp = i; for(j=0;ch[temp] != '\0';j++,temp++) ch3[j] = ch[temp]; ch3[j]='\0'; for(j=0;j<strlen(ch);j++,i++) ch[i] = ch2[j]; strcat(ch,ch3); ch[i] = '\0'; puts(ch);}
用C语言编写程序:输入一个字符?
#include<stdio.h>#include<string.h>void main(){ char ch[40],ch2[20],ch3[20],i,j,temp,x; printf("请输入第一串字符:"); gets(ch); printf("请输入第二串字符:"); gets(ch2); printf("请输入插入的位置:"); scanf("%d",&i); temp = i; for(j=0;ch[temp] != '\0';j++,temp++) ch3[j] = ch[temp]; ch3[j]='\0'; for(j=0;j<strlen(ch);j++,i++) ch[i] = ch2[j]; strcat(ch,ch3); ch[i] = '\0'; puts(ch);}
怎样用C语言写一个程序,打开记事本,并输入一段文字?
#include <stdlib.h>#include <stdio.h>#define Line ***int main(){ //文件名及文件指针 char infile[]="D:\\Wtmp\\1.txt"; char outfile[]="D:\\Wtmp\\2.txt"; FILE *fpi,*fpo; //暂存器 char *outbuf; outbuf = (char *)malloc(Line*sizeof(char))
; if( ( fpi=fopen(infile,"r") ) == NULL ) { printf("文件打开%s失败\n",infile)
; return 3; } if( ( fpo=fopen(outfile,"w") ) == NULL ) { printf("文件打开%s失败\n",outfile)
; return 3; } while(1) { //outbuf要干净 //memset(outbuf,0,Line); outbuf=0; fprintf(fpo,"%s",outbuf)
; if (fgets(outbuf,Line,fpi)==NULL) { break; }//全部行结束退出循环 //DelStr(outbuf,"删除字符串")
; //重载函数DelStr //DelStr(outbuf,"要替换字符串","替换成字符串")
; //重载函数DelStr fprintf(fpo,"%s",outbuf); } //关闭文件 free(outbuf); fclose(fpi); fclose(fpo); return 0;}
到此,以上就是小编对于c语言写一的问题就介绍到这了,希望介绍关于c语言写一的3点解答对大家有用。