My program is skipping some statements.

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jun 2007
Posts: 12
Reputation: Jaav is an unknown quantity at this point 
Solved Threads: 1
Jaav Jaav is offline Offline
Newbie Poster

My program is skipping some statements.

 
0
  #1
Jun 21st, 2007
I have no idea why.
The lines it's skipping is the system("PAUSE");.
Not the first two but the last two.

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. char Big, Small;
  7. Big='Z';
  8. Small='z';
  9. printf("Z=%d.\nz=%d.\n",Big,Small);
  10. system("PAUSE");
  11. int X,Y;
  12. X=72;
  13. Y=104;
  14. printf("74=%c.\n104=%c.\n",X,Y);
  15. system("PAUSE");
  16. double DblNum = 123.456;
  17. printf("f=%f.\nScientific=%e.\ntestF=%F.\n",DblNum,DblNum,DblNum);
  18. system("PAUSE");
  19. char Newline = '\n';
  20. printf("newline=%d.\n",Newline);
  21. system("PAUSE");
  22. return 0;
  23. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,454
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: My program is skipping some statements.

 
0
  #2
Jun 21st, 2007
worked ok for me on Vista using VC++ 2005 Express. If you are using *nix maybe it does not have a pause shell command ???
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 12
Reputation: Jaav is an unknown quantity at this point 
Solved Threads: 1
Jaav Jaav is offline Offline
Newbie Poster

Re: My program is skipping some statements.

 
0
  #3
Jun 22nd, 2007
I just tried it in VC++ express now too and it worked.
I used Dev-C++ before.
I guess i'm not going to be using Dev-C++ again.

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 12
Reputation: Jaav is an unknown quantity at this point 
Solved Threads: 1
Jaav Jaav is offline Offline
Newbie Poster

Re: My program is skipping some statements.

 
0
  #4
Jun 22nd, 2007
I got the same problem in another program I made using VC++ express now.
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int main()
  5. {
  6. putchar(66);
  7. putc(121,stdout);
  8. putchar(101);
  9. putchar(10);
  10. system("PAUSE");
  11.  
  12. int in = 123;
  13. int floa = 123.456;
  14. printf("%-3d\n%-6.3f\n",in,floa);
  15. system("PAUSE");
  16. }

It ignores the last system("PAUSE"); but not the first one.
I need to know what causes these problems.
Dev-C++ wasn't the only compiler with this problem.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,454
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1476
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: My program is skipping some statements.

 
0
  #5
Jun 22nd, 2007
Its not the compiler -- your program contains a bug line 13 -- change the data type to float and it will probably work as expected.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 12
Reputation: Jaav is an unknown quantity at this point 
Solved Threads: 1
Jaav Jaav is offline Offline
Newbie Poster

Re: My program is skipping some statements.

 
0
  #6
Jun 22nd, 2007
Oh yea, sorry

Thanks
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,623
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 468
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: My program is skipping some statements.

 
0
  #7
Jun 22nd, 2007
Its always a good practice not to ignore warnings which appear when you compile your code. A warning about 'converting from float to int' would have given you the reason why your program is not working.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC