Simple method terrible implementation
ok so i am new to C and pointers, that being said please forgive me for what must be really crappy code.
i want to rewrite a string so that all the characters in it become upper case
this is the method im having trouble with; when my code reaches it, it gets a segmentation fault (NOoOOooOoO)
Code:
void encode(char * str){
char charAt;
char *temp = malloc (1000*sizeof(char));
int i=0;
while (*str != EOF)
{
charAt = *str;
charAt = toupper(charAt);
temp[i]=charAt;
i++;
str++;
}
*str = temp;
}