Thread: problem with programming in C

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    3

    Unhappy problem with programming in C

    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?

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    http://faq.cprogramming.com/cgi-bin/...&id=1043284385

    always read the faq before posting..
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  3. #3
    Registered User
    Join Date
    Mar 2005
    Posts
    36
    i dont know which compiler your using but if your using visual c++ you shout run the program using shift f5

  4. #4
    Registered User
    Join Date
    Mar 2005
    Posts
    3

    thnx but doesnt help

    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?

  5. #5
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    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:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  6. #6
    Registered User
    Join Date
    Mar 2005
    Posts
    37

    solution to your problem..

    Quote Originally Posted by yairzarka
    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?

    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..

  7. #7
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    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..
    getch() is very compiler specific..because conio.h is highly nonportable..getchar() is better
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  8. #8
    Registered User
    Join Date
    Mar 2005
    Posts
    3
    Quote Originally Posted by Machoscorpion
    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..

    it now works perfectly! thanks alot. now i can start to proparly learn C...

  9. #9
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by yairzarka
    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.

    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM