Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 6th, 2006, 2:23 PM   #41
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
What I meant to say is there's no reason NOT to move to C#. :-)
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jul 6th, 2006, 2:25 PM   #42
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
A comment on your program: From what I've seen of your posts in PFO, you seem to have a good command of English. I'd DEFINITELY recommend giving your identifiers (variable and function names, etc.) English names, and writing your comments in English as well. Trust me, there are far more programmers who would understand "name" than "navn".
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jul 6th, 2006, 2:26 PM   #43
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,473
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
"(I'm hoping I don't have to learn c++ first... no special reason, just want to start with C#)"

You don't have to know C++ to begin C#. Once you know one language, in my opinion, its just a matter of learning the syntax and features of the next language. The only "bad" thing about C# is that it is not as cross-platform as some of the other languages. C# is primarily for windows, yet there is the Mono Project that tries to port it over to Linux, etc. I suggest going to C# as early as you want to, if you desire... pick up C++ after C#. Knowing multiple languages is always a good idea.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Jul 6th, 2006, 2:45 PM   #44
thondal
Programmer
 
thondal's Avatar
 
Join Date: Jan 2006
Location: Norway
Posts: 82
Rep Power: 3 thondal is on a distinguished road
Send a message via MSN to thondal
Quote:
Originally Posted by uman
A comment on your program: From what I've seen of your posts in PFO, you seem to have a good command of English. I'd DEFINITELY recommend giving your identifiers (variable and function names, etc.) English names, and writing your comments in English as well. Trust me, there are far more programmers who would understand "name" than "navn".
yeah i know... I was just going to do that next, was reading my code and wondering what I was doing , but my english vocabulary and spelling has been getting worse the last months, but I guess that's just a result of not writing enough... oh well... any other comments on the program?

-thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was.
thondal is offline   Reply With Quote
Old Jul 6th, 2006, 3:12 PM   #45
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
When I read your posts I don't notice anything that would tip me off to the fact that you're not a native speaker... your English is very good.

As others have said you shouldn't use gets as it's susceptible to buffer overflows.

Your program seems to be a good start... good luck!
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials.
--WilliamSChips on Slashdot
uman is offline   Reply With Quote
Old Jul 6th, 2006, 3:47 PM   #46
thondal
Programmer
 
thondal's Avatar
 
Join Date: Jan 2006
Location: Norway
Posts: 82
Rep Power: 3 thondal is on a distinguished road
Send a message via MSN to thondal
so, instead of gets what should I use? the scanf? or?

-thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was.
thondal is offline   Reply With Quote
Old Jul 6th, 2006, 5:14 PM   #47
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
fgets, it allows you to set a maximum number of input characters (can't overflow if you set it correctly). It requires one additional argument, the file pointer, just use stdin (and check your docs). Did someone actually teach you to use gets?:eek:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Jul 6th, 2006, 6:08 PM   #48
thondal
Programmer
 
thondal's Avatar
 
Join Date: Jan 2006
Location: Norway
Posts: 82
Rep Power: 3 thondal is on a distinguished road
Send a message via MSN to thondal
Quote:
Originally Posted by DaWei
fgets, it allows you to set a maximum number of input characters (can't overflow if you set it correctly). It requires one additional argument, the file pointer, just use stdin (and check your docs). Did someone actually teach you to use gets?:eek:
que?
I really did not understand that , (I'm not done with the C dummies book yet) fgets it's better? fgets stands for formatted gets or something right, and then the stdin is? Really appreciate the help, I'm just a slow learner...

-thondal-
__________________
"die" he screamed at the polygon man. When he was done with him, only four points remained, a quad of what he once was.
thondal is offline   Reply With Quote
Old Jul 6th, 2006, 6:35 PM   #49
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by thondal
I really did not understand that , (I'm not done with the C dummies book yet) fgets it's better? fgets stands for formatted gets or something right, and then the stdin is? Really appreciate the help, I'm just a slow learner...
Essentially, it's because gets does not check to see if it has exceeded the length of the array it's putting the answer in. If you have a string of 10 characters, and the user enters 20 characters, then the extra characters will spill over into other parts of the program's memory. This is known as a buffer overflow vulnerability, and represents a security risk. A malicious user can use this vulnerability to inject code into your running program.

fgets allows you to specify a limit to prevent this type of vulnerability:
char buffer[10];
fgets(buffer, 10, stdin);
fgets can get information from any stream, such as from a file. The stdin stream represents the standard user input into a program.
Arevos is offline   Reply With Quote
Old Jul 6th, 2006, 8:20 PM   #50
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You have an older version of C for Dummies, by the sounds of things... if you can find a newer one, I suggest "upgrading". The older ones teach some bad techniques. In the mean time, remember, gets is bad.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:57 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC