1. scanf & printf
printf函数和scanf函数 ?
2. gets & puts
gets
char *gets(char *str)
#include <stdio.h>
int main()
{
char str[50];
printf("请输入一个字符串:");
gets(str);
printf("您输入的字符串是:%s", str);
return(0);
}
puts
int puts(const char *str)
#include <stdio.h>
#include <string.h>
int main()
{
char str[20];
strcpy(str, "hello world!");
puts(str);
return(0);
}
?
3. getc & puts
getc
int getc(FILE *stream)
#include<stdio.h>
int main()
{
char c;
printf("请输入字符:");
c = getc(stdin);
printf("输入的字符:");
putc(c, stdout);
return(0);
}
putc
int putc(int char, FILE *stream)
#include <stdio.h>
int main ()
{
FILE *fp;
int ch;
fp = fopen("file.txt", "w");
for( ch = 33 ; ch <= 100; ch++ )
{
putc(ch, fp);
}
fclose(fp);
return(0);
}
|