The problem in my simple learning program is the, basically, it doesn't work and it prints out Segmentation fault (core dumped). I just want to know why it does that and what are the possible solutions.
EDIT: That's not really the main problem. Even if I just assign a value to input, it still prints out the error.
Code:#include <stdio.h>#include <string.h> char *cap(char *); int main(int argc, char *argv[]) { char *input = "Hello World!"; printf("CAPITALIZED: "); cap(input); return 0; } char *cap(char *input) { int i, n; for(i = 0, n = strlen(input); i < n; i++) { if(input[i] >= 'a' && input[i] <= 'z') { input[i] -= ('a' - 'A'); printf("%c", input[i]); } printf("\n"); } }



2Likes
LinkBack URL
About LinkBacks



