Lab 3 - IDA
Lab 3 - IDA
Lab 3 - IDA
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Lab</strong> 3 (B): Program arguments<br />
• STEP 1: Break the string in to parts<br />
– Use strtok_r() in lib/string.[ch]:<br />
– Example exec(“insult s 17 ”);<br />
char s[] = "insult s 17 "; const char delim[] = ” ”;<br />
char *token, *save_ptr;<br />
for (token = strtok_r (s, delim, &save_ptr);<br />
token != NULL;<br />
token = strtok_r (NULL, delim, &save_ptr))<br />
Output:<br />
printf ("'%s' ", token);<br />
'insult' 's' '17'<br />
Warning: the string s is modified<br />
23