wocao58 2017-01-11 13:30 采纳率: 100%
浏览 1226
已采纳

关于C语言strcpy函数问题

这个代码是直接照着c primer plus第五版 上面的程序写的了,但是运行起来还是有错误,主要问题是strcpy这个函数,下面是报错截图。
图片说明

 #include <stdio.h>
#include <conio.h>
#include <string.h>
#define LEM 5
#define SIZE 40

int main(void)
{
    char qwords[LEM][SIZE];
    char temp[SIZE];
    int i = 0;

    printf("Enter %d words begin with q:\n", LEM);
    while (i < LEM && gets_s(temp, SIZE))
    {
        if (temp[0] != 'q')
            printf("%s doesn't begin with q!\n", temp);
        else
        {
            strcpy(qwords[i], temp);
            i++;
        }
    }
    puts("Here are the words accepted:");
    for (i = 0; i < LEM; i++)
        puts(qwords[i]);

    return 0;
}
  • 写回答

3条回答

  • YXTS122 2017-01-11 14:17
    关注

    strcpy_s(qword[i],40,temp);改为这样试试

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题