C语言自学路之逐字打印

涉及知识点:char形数组、strlen函数、Sleep、引头文件 string.h 和 windows.h

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#define N 20

int main()
{
int i;
char hello[30]={"What's your name?"};
char name[30]={"Hello,"};//一个用来存储用户名字的字符串数组

for(i=0;i<=strlen(hello);i++)
{
  printf("%c",hello[i]);
  Sleep(50);
}
putchar('\n');
scanf("%s",&name[6]);
for(i=0;i<=strlen(name);i++)
{
  printf("%c",name[i]);
  Sleep(50);
}
return 0;
}

更多推荐

C语言自学路之逐字打印