| | |
Playing with strings
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I am working on a project that requires me to recive data from a network application. After I recive the data I'm suppose to break it up. Now I know of a way to sorta do that by using "tokens" and strtok (if you don't know strok breaks up a string by delminating character i.e. \n ). My problem is that I need to do it twice. Once for "\n" and once for "\t", but my program crashes when I use strtok a second time. For example:
This works, but doesn't give to resluts needed. I need to break it further up, however:
crashes the program.
Any ideas on how to work this out?
C Syntax (Toggle Plain Text)
tokenPtr = strtok (m_pBuf , "\n"); while ( tokenPtr != NULL ) { temp[i] = tokenPtr; tokenPtr = strtok(NULL, "\n"); i++; }
C Syntax (Toggle Plain Text)
tokenPtr = strtok (m_pBuf , "\n"); while ( tokenPtr != NULL ) { temp[i] = tokenPtr; tokenPtr = strtok(NULL, "\n"); i++; } while ( count <= i ) { tokenPtr = strtok (temp[count] , "\t"); while ( tokenPtr != NULL ) { temp2[j] = tokenPtr; tokenPtr = strtok(NULL, "\t"); j++; } count++; tokenPtr = ""; }
Any ideas on how to work this out?
![]() |
Similar Threads
- computer freezes when playing games (Troubleshooting Dead Machines)
- Playing .Wav/MIDI files in a Visual Basic Program (Visual Basic 4 / 5 / 6)
- Compare strings... (C++)
- Computer freezes while playing GAMES (Troubleshooting Dead Machines)
- comparing two strings with linear search.. (Java)
- Computer generated lag while playing MOHAA (Troubleshooting Dead Machines)
- JSP and Oracle (JSP)
Other Threads in the C Forum
- Previous Thread: Algorithm Efficiency Help!!!!
- Next Thread: Type casting and type conversions
| Thread Tools | Search this Thread |
Tag cloud for C
#include ansi array arrays asterisks binarysearch calculate centimeter changingto char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc database directory dynamic fflush file fork forloop framework functions getlasterror givemetehcodez grade graphics gtkgcurlcompiling hacking hardware histogram homework inches include incrementoperators input iso kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives looping loopinsideloop. lowest match matrix microsoft motherboard multi mysql number opendocumentformat opensource owf pattern pdf performance pointer posix problem probleminc process program programming radix recursion recv research reversing scanf scripting segmentationfault sequential shape socket socketprograming spoonfeeding standard string strings structures student systemcall testing threads turboc unix user variable voidmain() wab windowsapi






Thank you so much. (In answer to your question, I didn't know I could do that and make it work right. It doesn't seem like it would, but it does!) Thank you again!