What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » C - vectors

C - vectors
Author: Message:
TheSteve
Full Member
***

Avatar
The Man from Japan

Posts: 179
Reputation: 23
40 / Male / Flag
Joined: Aug 2005
RE: C - vectors
Keep in mind that strlen() will only work if your string has a null character at the end.  In the case of scanf, it should be null terminated as long as the user doesn't input more than 19 characters.   (more than that and the program could crash or just act strangely of course.)
quote:
Originally posted by RaceProUK
quote:
Originally posted by Chancer
code:
char word[20];
scanf ("%s", word);

Bye-bye program :P
Not always.  Depending on how much data is inputed in to the program, and how much other data is on the stack, it could just overwrite the other variables in the function. Even if the data size does exceed the current stack frame, there's always going to be a chance that the return address is going to be overwritten by a random, but valid memory address, which would cause a very interesting situation to debug. :P

This post was edited on 06-16-2008 at 05:29 AM by TheSteve.
06-16-2008 05:28 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
C - vectors - by Chancer on 06-15-2008 at 01:53 AM
RE: C - vectors - by Mnjul on 06-15-2008 at 11:12 AM
RE: C - vectors - by Chancer on 06-15-2008 at 08:34 PM
RE: C - vectors - by TheSteve on 06-16-2008 at 05:28 AM
RE: C - vectors - by Chancer on 06-19-2008 at 01:57 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On