i have a problem with programming in C. Each time i run a program it doesnt stay open for more then a milisecond. does anyone have a sujestion?
i attached the most basic program. is there anything that im missing?
i have a problem with programming in C. Each time i run a program it doesnt stay open for more then a milisecond. does anyone have a sujestion?
i attached the most basic program. is there anything that im missing?
http://faq.cprogramming.com/cgi-bin/...&id=1043284385
always read the faq before posting..
Code:>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
i dont know which compiler your using but if your using visual c++ you shout run the program using shift f5
thnx for your tip but this only works for a very simple program. i tried it on another program but it didnt work(attached). got another idea? is it just something local on my pc or is it something with the program?
what you are doing in the program is wrong..you are first waiting for input and then you do a return 0 and after that you try to find the average and print it..when you do a return 0, the program ends..so the lines ahead are not going to get executed.
Code:>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
Originally Posted by yairzarka
Hey what you can do is ...
# include <conio.h>
and once you done with the program, just before you call return 0 just put a statement getch();
this statement will wait till you enter a key from the key board..
Ok.. let me know how it went.. bye..
getch() is very compiler specific..because conio.h is highly nonportable..getchar() is betterHey what you can do is ...
# include <conio.h>
and once you done with the program, just before you call return 0 just put a statement getch();
this statement will wait till you enter a key from the key board..
Code:>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.
Originally Posted by Machoscorpion
it now works perfectly! thanks alot. now i can start to proparly learn C...
Not really. Because as stated, you're not using standard C functions now. You're "fixing" your problem by using non-standard functions. Which means, when you run into another compiler, your "fix" will no longer work.Originally Posted by yairzarka
Of course you could have just read the FAQ, which would have answered this question for you.
Quzah.
Hope is the first step on the road to disappointment.