![]() |
|
#1
|
|||
|
|||
Passing strings in functions..HELP please...I am new to programming and need some help,
I want to pass a string into a function that uses strtok(), or something else, to check for spaces or tabs and then return the first non-space-containing-word to main... This seems to be an impossible task. My code looks like this: CPP / C++ / C Code:
It works if i write printf("%s", strtok(test_string, " \t\n")); in main, Why doesnt it work in the function?? thanx Last edited by dsmith : 24-May-2004 at 08:21.
Reason: Please use [c] & [/c] to highlight code
|
|
#2
|
||||
|
||||
|
Hi mgdpetter, welcome to GID Forums, I think you should read this first C++ Tags it shows how to post your code for better looks and readablity..
I'm not exactly sure why your code doesn't work.What I see is that strtok return a char * and I made the functin to return the char*: CPP / C++ / C Code:
__________________
When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." Linus Torvalds |
|
#3
|
|||
|
|||
|
Thanx man. Now it works.
you're a legend. I'll use the C tags in the future.. Thanx again. |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Including Maps and strings?? | maddie | C++ Forum | 17 | 05-Jul-2004 07:25 |
| Help on passing in arrays in functions? | nusstu | C Programming Language | 10 | 02-Apr-2004 11:42 |
| Understanding functions | tommy69 | C Programming Language | 15 | 15-Mar-2004 18:59 |
| Passing Pointers To Pointers in Functions | elumira | C Programming Language | 8 | 05-Mar-2004 22:23 |
| New to C...need help calling functions | rbeierle | C Programming Language | 3 | 10-Feb-2004 19:46 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The