lundi 24 septembre 2018

Alter a char* passed through a void function in C++ without using libraries

I can't use anything but basic cout and cin for this and I have been having trouble all day.

Currently all I need to know how to do is alter a char* in a void function

void to_hostname(char *address)
{
address[0] = 'Q';
}

but for some reason this always gives me a Segmentation fault. The assignment requires me to alter the address from within itself.

so for example https://www.HeLLO.cOm/hi.plod.

Should be altered so that address becomes www.hello.com

I would appreciate any help I can get as this has been kicking my butt for hours now.

Aucun commentaire:

Enregistrer un commentaire