|
||||||
| 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 08:53 AM |
| assembly code help | emaney | General Programming | 0 | 06-16-2007 04:27 AM |
| Please Help With A C Program!! | siren | C and C++ | 7 | 04-17-2007 08:45 AM |
| Where to Put PHP Code | clookid | PHP Tutorials | 1 | 01-11-2007 08:44 PM |
| John | ........ | 223.00000 |
| dargueta | ........ | 168.00000 |
| Xav | ........ | 164.00000 |
| gaylo565 | ........ | 18.00000 |
| WingedPanther | ........ | 15.00000 |
| |pH| | ........ | 15.00000 |
| Johnnyboy | ........ | 3.00000 |
| navghost | ........ | 1.00000 |
Goal: 100,000 Posts
Complete: 65%