刘加加在成长(C++语言学习中)

学习、工作、生活,这是三个问题。

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  38 随笔 :: 0 文章 :: 24 评论 :: 0 Trackbacks
下面代码演示了程序循环从用户输入读取字符串,并存入临时的字符串数组,然后将临时字符串复制到qwords数组里面。

#include<stdio.h>
#include
<string.h>
#define SIZE 40
#define LIM 5
int main(void)
{
    
char qwords[LIM][SIZE];
    
char temp[SIZE];
    
int i=0;
    
    
while(i<LIM && gets(temp))
    {
        strcpy(qwords[i],temp);
        i
++;
    }
    puts(
"The list");
    
for(i=0;i<LIM;i++)
    {
        puts(qwords[i]);
    }
    
    getchar();
    
return 0;
}
posted on 2008-05-30 23:57 刘加加 阅读(2666) 评论(0)  编辑 收藏 引用 所属分类: 学习C语言

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理