Hello all,
I'm trying to create a simple routine where I transform the individual characters of a character string to uppercase. I'm trying to figure out why I can dereference individual elements, but can't assign to them. I must be committing some fundamental mistake, but my book pretty much has the same logic I'm using. Any hints? Thanks in advance, as usual!
Code:
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
char *c = "hello!";
int i;
for( i = 0; *(c+i) != '\0'; i++){
if(islower(*(c+i))){
*(c+i) = toupper(*(c+i)); //boom! Why?
}
}
}