944,131 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 1107
  • C RSS
Jun 21st, 2007
0

My program is skipping some statements.

Expand Post »
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. }
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Jaav is offline Offline
12 posts
since Jun 2007
Jun 21st, 2007
0

Re: My program is skipping some statements.

worked ok for me on Vista using VC++ 2005 Express. If you are using *nix maybe it does not have a pause shell command ???
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005
Jun 22nd, 2007
0

Re: My program is skipping some statements.

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Jaav is offline Offline
12 posts
since Jun 2007
Jun 22nd, 2007
0

Re: My program is skipping some statements.

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Jaav is offline Offline
12 posts
since Jun 2007
Jun 22nd, 2007
0

Re: My program is skipping some statements.

Its not the compiler -- your program contains a bug line 13 -- change the data type to float and it will probably work as expected.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005
Jun 22nd, 2007
0

Re: My program is skipping some statements.

Oh yea, sorry

Thanks
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Jaav is offline Offline
12 posts
since Jun 2007
Jun 22nd, 2007
0

Re: My program is skipping some statements.

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.
Super Moderator
Featured Poster
Reputation Points: 3241
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,873 posts
since Jun 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: structure
Next Thread in C Forum Timeline: guideline for C++(beginer)





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


Follow us on Twitter


© 2011 DaniWeb® LLC