请编写函数mygets和myputs,其功能分别与gets和puts相同,函数中用getchar和putchar读入和输出字符

如题所述

第1个回答  2010-09-15
//在DEV-CPP测试通过
#include<stdio.h>
#include<string.h>

char s[100];

void mygets()
{
int i=0;
char c;
do
{
c=getchar();
s[i]=c;
i++;
}
while(c!='\n');
}

void myputs()
{
int i=0;
char c;
while(s[i]!='\0')
{
putchar(c);
c=s[i];
i++;
}
}

int main()
{
mygets();
myputs();
system("pause");
return 0;
}
相似回答