int sk03(char * a) //DELETE! DELEEEEETE!
{ //(Or "Exterminate! EXTERMINAAAAAATE!" if that's your thing.)
int b = sk00(a);
int c = 0;
while(a[b] != '!')
{
a[c] = a[b];
c++;b++;
}
cout << a << "\n";
int your_mom = 0;
return your_mom;
}
int main()
{
char * str = "``sk`sk!";
return sk03(str);
}
当你想将整个字符串传递给函数时,这种方法可以正常工作,但是如何将字符串的后半部分传递给sk03?我是否必须创建一个完整的新阵列?
答案 0 :(得分:1)
不,你只需将指针传递给你想要的元素:
char a[100];
sk03( a + 50 ); // call function passing second half of the array
答案 1 :(得分:1)
传递
char * str = "``sk`sk!";
return sk03(&str[4]);
答案 2 :(得分:1)
char str[STRING_LENGTH] = "``sk`sk!";
return sk03(&str[3]);