I have a struct:
typedef struct entry {
char *surname;
int house_no;
char *postcode;
} BEntry;
and a function to convert strings to upper case:
void toUpper(char *str){
while (*str != '\0')
{
*str = toupper(*str);
str++;
}
}
and in my main function I assign values to the struct members and want to convert the surname to upper case:
mentry->surname = "bob";
mentry->house_no = 17;
mentry->postcode = "GK116BY";
toUpper(me->surname);
What is the correct way to convert a string to upper case by passing a char pointer to a function like this? My program is returning a segmentation fault. Any help is most appreciated, thanks.