所以,我想要做的是創建一個函數,將大寫字母切換爲小寫字母,反之亦然。小寫字母<-->大寫字母不能按計劃工作
這裏是我的工作:
#include <stdio.h>
#include <stdlib.h>
int caplowswitch(char string[], char switched[]);
int main(){
char name[] = "whyisthisnotworking";
char flipped[] = "";
caplowswitch(name, flipped);
return 0;
}
int caplowswitch(char word[], char switched[]){
char *ptrword = word;
unsigned short int counter = 0;
printf("Your text input is: %s \n", word);
while(*ptrword != NULL){
switched[counter] = (*ptrword^0x20);
counter++;
ptrword++;
}
printf("Your flipped text is: %s \n", switched);
return 1;
}
在學習的過程。謝謝你的時間。
而這不起作用...怎麼樣?我們應該猜測問題是什麼?我們在這裏幫助,而不是你的調試器。 –
你放入「*切換*」的字符在哪裏結束? (提示:不在數組中切換/翻轉,因爲這只是一個字符長。) –