I wrote a function that converts any letter from an array into lowercase, but I want the functionality to be in the main function without using the function I wrote. Somehow I cant do it or don't recognize my mistake:
this is my function:
void lower(char *a) { for (int n = 0; n < strlen(a); n++) { a[n] = tolower(a[n]); } }
and my main function:
int main(int argc, char ** argv) { if (strcmp(*(argv + 0), "./lower") == 0) { for (int i = 1; i < argc; i++) { for (int n = 0; n < strlen(argv[i]); n++) { **(argv+n) = tolower(**(argv+n)); } } for (int i = 1; i < argc; i++) { printf("%s\n", *(argv + i)); } return 2; } return 0; }
I want to do it in the if statement without the function, but don't know where the problem is. It works when I use my function.
https://stackoverflow.com/questions/65746098/array-initialization-spelling January 16, 2021 at 11:05AM
没有评论:
发表评论