|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
C Code:
Can anyone explain this to me? i know it parses with a delimeter but im not quite sure how it works |
| Sponsored Links |
|
|
|
|||
|
Here you go, comments added
![]() HTML Code:
char *local = strdup(tosplit); // makes a copy of tosplit, and
// returns a pointer to the allocated copy
char *tok = strtok(local, delim); // split local into tokens using
// delim, store the first token in tok
int i = 0; // counter for token
while(tok) { // while token is not null
*parsed++ = strdup(tok); // makes a copy of token,
// returns a pointer to the allocated copy which is stored in
// parsed, parsed is then increment to point to the next
// pointer
i++; // increment the number of tokens parsed
tok = strtok(NULL, delim); // get next token
}
*len = i; // stores the number of tokens in len
free(local); // frees the memory taken up local
// when the function returns, *parsed will contain tokens created from tosplit
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Basic Calculator | AfTriX | VB Tutorials | 3 | 02-29-2008 09:53 AM |
| assembly code help | emaney | General Programming | 0 | 06-16-2007 05:27 AM |
| Please Help With A C Program!! | siren | C and C++ | 7 | 04-17-2007 09:45 AM |
| Where to Put PHP Code | clookid | PHP Tutorials | 1 | 01-11-2007 09:44 PM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |