我试图使用for带有 ASCII 表的循环,通过用 32 减去字母数字来使字符串中的每个字符一一大写。但我不能i在 charstr和中使用 int str2。我怎样才能做到这一点?
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define STRLEN 200
void string_lower() {
}
void string_upper(char str) {
char str2;
int length = strlen(str);
for (int i = 0; i < length; i++) {
str2[i] = str[i - 32];
}
}
int main() {
char word[STRLEN] = { 0 };
char word1 = 97;
printf("Write a word");
fgets(word, STRLEN, stdin);
string_upper(word);
return 0;
}
Run Code Online (Sandbox Code Playgroud) c ×1