在C中右移数组w /(Abort Trap:6)

问题描述 投票:0回答:1

我的代码有问题。我想在第一个位置弹出一个char'_'到一个完整的数组。我写了这个,但终端给我看了一个Abort陷阱:6。你能帮助我吗?

//this code was deleted cause i had good answer! Sorry but is a school project and i couldn't post anything !

我不知道知道我使用mac OSX很重要

c arrays macos memory char
1个回答
3
投票

您正在使用strcat函数错误。第一个参数是目标,因为您传递的是字符串文字,所以它是未定义的行为。

strcpy(dupstr, "_");
strcat(dupstr, temp);

应该做的伎俩。

© www.soinside.com 2019 - 2024. All rights reserved.