The world is currently online!


Welcome to Emps-World!

Register now to gain access to all of our forum features. Once registered and logged in, you will be able to create topics, post replies, send private messages, manage your profile, chat with other players in the shoutbox and much more. Once you sign in, this message will disappear.



Pages: 1
0 Members and 1 Guest are viewing this topic.

Offline Ameer

  • *
  • 488
  • Liked: 631 times
  • +0/-0
    • View Profile
:/ C language again
« on: April 28, 2017, 10:03:22 am »


Any idea why for is not stopping ? even after it reaches i = 7 :/ [Seems like I found a way to fix this problem as well, sorry for wasting your time lads :/ ]

another question is, why is it printing 3 and 4 at the same time, instead of waiting for scanf to finish its job ? [ Fixed this problem by having a space before %c, changed from scanf("%c"&c); ---------> scanf(" %c" &c);


« Last Edit: April 28, 2017, 10:46:30 am by Ameer »



Emps-World Player Moderator Since July 18, 2015
Emps-World Game Moderator Since September 22, 2015
Emps-World Player Administrator Since  October 29, 2015
Emps-World Game Administrator since few years

Emps world player since the day I resigned, dunno when.

Offline Thomy

  • *
  • 3555
  • Liked: 3326 times
  • +5/-0
    • View Profile
Re: :/ C language again
« Reply #1 on: April 28, 2017, 10:19:52 am »
Please show the full code, else nobody can help you: https://pastebin.com/

You might want to disable input/output buffering. Add the following lines to your code directly under main:
Code: [Select]
setbuf(stdout, NULL);
setbuf(stdin, NULL);
« Last Edit: April 28, 2017, 10:24:27 am by Thomy »

Offline Ameer

  • *
  • 488
  • Liked: 631 times
  • +0/-0
    • View Profile
Re: :/ C language again
« Reply #2 on: April 28, 2017, 10:30:01 am »
Please show the full code, else nobody can help you: https://pastebin.com/

You might want to disable input/output buffering. Add the following lines to your code directly under main:
Code: [Select]
setbuf(stdout, NULL);
setbuf(stdin, NULL);

https://pastebin.com/teuaNEKU



Emps-World Player Moderator Since July 18, 2015
Emps-World Game Moderator Since September 22, 2015
Emps-World Player Administrator Since  October 29, 2015
Emps-World Game Administrator since few years

Emps world player since the day I resigned, dunno when.

Offline Ameer

  • *
  • 488
  • Liked: 631 times
  • +0/-0
    • View Profile
Re: :/ C language again
« Reply #3 on: April 28, 2017, 10:45:45 am »
Seems like I've found a way to fix the problem, thanks for your time anyway
I appreciate it ;)



Emps-World Player Moderator Since July 18, 2015
Emps-World Game Moderator Since September 22, 2015
Emps-World Player Administrator Since  October 29, 2015
Emps-World Game Administrator since few years

Emps world player since the day I resigned, dunno when.
The following users liked this post: Thomy

Offline Thomy

  • *
  • 3555
  • Liked: 3326 times
  • +5/-0
    • View Profile
Re: :/ C language again
« Reply #4 on: April 28, 2017, 10:51:21 am »
Sounds like a wrong pointer somewhere. Couldn't spot it by flying over your code. I'd recommend debugging it: https://www.gnu.org/software/gdb/ I've used gdb before for uni homeworks and found it useful.
The following users liked this post: Ameer

Offline Tulrak

  • *
  • 202
  • Liked: 667 times
  • +0/-0
    • View Profile
Re: :/ C language again
« Reply #5 on: April 28, 2017, 10:52:11 am »
Don't understand these things, but you probably want to add this (took your code from choice 3):
Code: [Select]
printMenu();
printf("Please enter your choice: ");
scanf("%d" ,&choice);
After line 87
Plus add the same thing after line 83

Currently if you enter 4 or 5 then the do-while loop will keep looping without giving you an option to pick something else. So it'll just loop back to 4 or 5.
The following users liked this post: Thomy, Ameer

Offline Ameer

  • *
  • 488
  • Liked: 631 times
  • +0/-0
    • View Profile
Re: :/ C language again
« Reply #6 on: April 28, 2017, 11:09:02 am »
Sounds like a wrong pointer somewhere. Couldn't spot it by flying over your code. I'd recommend debugging it: https://www.gnu.org/software/gdb/ I've used gdb before for uni homeworks and found it useful.

Will make sure to check the site you linked above, thanks ;)


Don't understand these things, but you probably want to add this (took your code from choice 3):
Code: [Select]
printMenu();
printf("Please enter your choice: ");
scanf("%d" ,&choice);
After line 87
Plus add the same thing after line 83

Currently if you enter 4 or 5 then the do-while loop will keep looping without giving you an option to pick something else. So it'll just loop back to 4 or 5.

That's actually what caused the problem ;P
it kept checking if ' Check ' was on 5 all the time which it returns true then goin all over the function again ;)


Thanks lads, I really appreciate it


I'll lock it for now as it has been solved, danks ;P



Emps-World Player Moderator Since July 18, 2015
Emps-World Game Moderator Since September 22, 2015
Emps-World Player Administrator Since  October 29, 2015
Emps-World Game Administrator since few years

Emps world player since the day I resigned, dunno when.
Pages: 1