簡體   English   中英

我不斷收到此異常 - 發生異常。 EXC_BREAKPOINT(代碼=1,子代碼=0x1b8c50bb0)

[英]I keep receiving this exception - Exception has occurred. EXC_BREAKPOINT (code=1, subcode=0x1b8c50bb0)

#include <stdio.h>
#include <string.h>

int main()
{
    char first[] = "This is the first part of";
    char second[] = "the full string, this being the second half\n.";
    char buffer[70];
    strcpy(buffer,first);
    strcat(buffer,second);
    puts(buffer);
    return 0;
}

我在 strcat function 上收到錯誤,請協助在此處輸入圖像描述

似乎數組buffer的大小不足以包含連接的字符串。

聲明它至少像

char first[] = "This is the first part of";
char second[] = "the full string, this being the second half\n.";
char buffer[sizeof( first ) + sizeof( second ) - 1];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM