[問題] 怎麼傳字串啊?

看板C_and_CPP (C/C++)作者 (Jisa)時間13年前 (2012/12/04 22:37), 編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/1
#include<stdio.h> #include<stdlib.h> int change(char &string[]); main(){ char words[] = "abcde"; printf("%s",words); change(words); printf("%s",words); system("pause"); } int change(char &string[]){ string[0]='1'; } 編譯的時候會出現 "[Error]] declaration of 'string' as array of references" 是錯在哪裡? p.s.第1次發文,如果有錯,請告訴我 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 36.224.41.30

12/04 22:44, , 1F
int change(char *string)
12/04 22:44, 1F

12/04 22:44, , 2F
char &string[] 改成 char *string 即可
12/04 22:44, 2F

12/05 19:30, , 3F
Thanks!!!
12/05 19:30, 3F

12/05 20:14, , 4F
抱歉 剛剛在忙沒接到水球
12/05 20:14, 4F
文章代碼(AID): #1GlWgUGL (C_and_CPP)
文章代碼(AID): #1GlWgUGL (C_and_CPP)