これが私のコードです:
void reverseStr(char *str)
{
if (str == NULL) return;
int i=0, j=strlen(str) -1;
while(i<j)
{
char temp = str[j]; //i think this is the cause of the problem
str[j] = str[i];
str[i] = temp;
i++;
j--;
}
}
だからここにそれが呼ばれるところです:
int main()
{
char *str = "Forest Gump";
reverseStr(str);
cout << str;
}
これが私のエラーです:
/Applications/TextMate.app/Contents/SharedSupport/Bundles/C.tmbundle/Support/bin/bootstrap.sh:7行目:1931バスエラー "$ 3" .out
何かご意見は?前もって感謝します。