setting a character array with spaces?

I'm reviewing for an exam tomorrow, and the old tests I've seen include the question:

Given the following code, in a single line set my_string to have the value “if I do this problem with multiple lines of code, I will be sitting here forever”.

char my_string[888];

I can't figure it out, I'm sure its something incredibly simple, but im in full retard mode at the moment.
To set c-style strings (char arrays), use the strcpy function.
my_string[0]='i',my_string[1]='f',my_string[2]=' ',my_string[3]='I',my_string[4]=' ',my_string[5]='d',my_string[6]='o',...,my_string[78]='e',my_string[79]='r',my_string[80]='\0';

Or, if you're allowed to #include<cstring> (not specified in the question), then:

std::strcpy(my_string, "if I do this problem...I will be sitting here forever");
Last edited on
thank you shacktar, strcpy is what they're asking for. been pulling my hair out wondering why i couldn't figure this out.
Topic archived. No new replies allowed.