-
Pretty Dumb Question
Ok, can anybody tell me how I can read this combination of text and variables into a character array?
Code:
"Roster Starts at: ";
date;
"\n\nRostered Shifts...\n\n";
"MONDAY :: ";
mo_one;
" -- ";
mo_two;
"\n\nTUESDAY :: ";
tu_one;
" -- ";
tu_two;
"\n\nWEDNESDAY :: ";
we_one;
" -- ";
we_two;
"\n\nTHURSDAY :: ";
th_one;
" -- ";
th_two;
"\n\nFRIDAY :: ";
fr_one;
" -- ";
fr_two;
"\n\nSATURDAY :: ";
sa_one;
" -- ";
sa_two;
"\n\nSUNDAY :: ";
su_one;
" -- ";
su_two;
Thanks
-
An array can not be of mxed types. You can use an array of pointers.
I'm not sure about this one but I would set up a structure the create an array of structures.
-
lot's of assumptions but maybe something like this?:
char comma[] = ",";
char buffer[500];
strcpy(buffer, "Roster starts at:")
strcat(buffer, comma);
strcat(buffer, date);
strcat(buffer, comma);
strcat(buffer, "Monday :: ");
//etc.
assumption #1: all variables are strings
assumption #2: you want just a unidimensional array of char and not an array of strings.
assumption #3: no other commas are allowed in the input except as delineators
-
sprintf( buffer, "The %i way to do that %.2f%% of the time would be %s", 1, 100.00, "this...\n"); :D
-
Yes, I think i'll just use strcpy() to add all the string onto the buffer. Thanks for helping...