If I have 3 source like \"a b c\", how do I separate a from b from c? struct tar
ID: 3642417 • Letter: I
Question
If I have 3 source like "a b c", how do I separate a from b from c?struct target *t = target_start;
char *source_start = p_colon+1;
while (*source_start == ' ' || *source_start == ' ')
{ source_start++; }
char *source_end = source_start;
while (*source_end == ' ' || *source_end == ' ')
{ source_end--; }
char *p_space = strchr(source_start,' ');
//while(p_space != NULL)
//list_sources_append(&sources, source_start);
list_targets_append(&sources, t->source = source_start);
source_end++;
*source_end = '';
Explanation / Answer
Take a look at this: char input[100] = "a b c"; char* t; t = strtok(input, " "); while(t != NULL) { // DO STUFF WITH t HERE t = strtok(NULL, " "); }
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.