943,519 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 2929
  • C RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Aug 29th, 2007
1

Re: Stupid Question

Quote ...
  1. system("pause"); //stdio.h
system is in stdlib.h, not stdio.h. It's not a good idea either because now you depend on an outside program that might be malicious. It's a big security no-no because you created a hole that hackers can use to break into your program.
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Aug 29th, 2007
0

Re: Stupid Question

Click to Expand / Collapse  Quote originally posted by SpS ...
Since some compilers (and lint) will warn about discarded return values, an explicit cast to (void) is a way of saying "Yes, I've decided to ignore the return value from this call.
lint is outdated, compilers have now good enough error checking, so that we don't need lint. gcc at least doesn't give such warning even when all warnings are on, i don't know any compiler which gives such warning, though maybe there is some.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 29th, 2007
0

Re: Stupid Question

Click to Expand / Collapse  Quote originally posted by TkTkorrovi ...
lint is outdated, compilers have now good enough error checking, so that we don't need lint.
Apparently you must be speaking from ignorance of the capabilities of a modern linter.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Aug 29th, 2007
0

Re: Stupid Question

Apparently you must be speaking from ignorance of the capabilities of a modern linter.
I likely don't know, what you call the "modern linter", but does it really demand (void) before some function calls? When the function's return value was not used, this means that we didn't need it, no need for such warnings.
Reputation Points: 85
Solved Threads: 13
Junior Poster
TkTkorrovi is offline Offline
170 posts
since Mar 2005
Aug 29th, 2007
2

Re: Stupid Question

Click to Expand / Collapse  Quote originally posted by TkTkorrovi ...
I likely don't know, what you call the "modern linter", but does it really demand (void) before some function calls? When the function's return value was not used, this means that we didn't need it, no need for such warnings.
It doesn't demand it, and it is rather easy to turn off that particular warning.

My frame of reference is PC-lint. This is not an ad, but some features it lists -- some of which I have used in the past -- are as follows.
Last edited by Dave Sinkula; Aug 29th, 2007 at 10:48 pm.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Aug 30th, 2007
0

Re: Stupid Question

you can use :

int main( void )
{
printf( "\t\"whoops\b\b\b\bew\n\"\n");

system("pause"); //stdio.h

return 0;
}
I found out what the deal was.... instead of creating a new source file, i created a new project. When creating a new file, my tool writes this in the file as part of the template:
  1. system("pause");

All good information though, thanks!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Lost in Code... is offline Offline
22 posts
since Nov 2006
Aug 30th, 2007
0

Re: Stupid Question

Quote ...
system("pause")
It works but it is platform dependant and incurrs a lot more overhead than getchar(). Most C/C++ developers of any ilk will tell you not to use system("pause").

If you search on this site or using Google you can find plenty of lengthy explanations why it's not a good practice.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005
Aug 30th, 2007
0

Re: Stupid Question

I found out what the deal was.... instead of creating a new source file, i created a new project. When creating a new file, my tool writes this in the file as part of the template:
  1. system("pause");
Edit the template to get rid of that awful command. I did...
Moderator
Reputation Points: 3275
Solved Threads: 890
Posting Sage
WaltP is offline Offline
7,716 posts
since May 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Dll
Next Thread in C Forum Timeline: Scanning (with TWAIN)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC