Thread: pointer error
View Single Post
Old 07-12-2006, 12:51 PM   #4 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
For your strtoc() question I would suggest you read a thread here which will show you, that you shouldn't allocate memory for your token, since it's just a pointer to the memory you're searching through ie. input_file.
For explanation on how strtok() works, you might want to read this thread.

For your lookupDictionary(), you might want to rethink it...
Code:
while (temp->string != word)
	{
Just read it again, and rethink that....
Is this C or is it C++, from what I can read, it is highly C, and not relying on the std::string container from C++.
Might I suggest a call to strcmp() or strncmp() for buffer-overflow security, or perhaps strcasecmp() if it isn't a casesensitive search. I know the last two aren't ANSI/ISO specific, but from what you describe it seems you're in a POSIX environment, where they are available from the strings.h header.

The thread mentioned earlier, also uses alot of pointer-arithmetic, so you might learn a wee bit from reading that code, in order to understand derefferencing pointers.

In regards to the "editing earlier posts", this has been an issue in the past, where people would simply delete or edit the first post, when they found the answer, so you wouldn't know what problem orriginaly spawned the thread..
To prevent that we had to specify that a normal user is only allowed to edit their post within 10 minuts from first submitting.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001

Last edited by redhead; 07-12-2006 at 01:09 PM.
redhead is offline   Reply With Quote