Thread: Help? New to C and getting trouble.

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    83

    Thumbs up Help? New to C and getting trouble.

    Dear guys..
    i m new to C language and there is alot of difficulties i m facing.even i m not able to compile a simple c programme in MS visual C++ 6 and Boroland C++ 5.02. but i never get out put....fact is that i dont know how to use those compiler...

    When it comes to use dos based Turbo C or C++ then it is not working well in my computer and it just shut down my computer because of alot of heat generation.

    Dont know what to do? help me to find a good compiler and its tutorial. please help.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Your first action should be to fix the cooling problem with your system. If it can't run Turbo C, it's probably not good to run any other CPU intensive application either.

    Either Borland or Visual Studio should be fairly easy to use, so perhaps you can post some code that you believe should work and we will have a look to see what may be wrong.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    83
    I feel embressed but there is simpe code ....how can i see the output of this file in borolandC++ 5.02.
    Code:
    #include<stdio.h>
    main()
    {
    int p,n;
    float r,si;
    p=1000;
    n=2;
    r=1;
    si=p*n*r/100;
    printf("&#37;d",si);
    }
    Now how can i get the out put ? I m able to compile it in Boroland C++ 5.02 but never got the out put...

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Haven't you tried running the program?

    Incidentally, it may be better to test with something simpler, e.g.,
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        printf("Hello world!");
        return 0;
    }
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    si is a float. You should code
    Code:
    printf("&#37;f",si);

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I have to agree with matsp. Your computer needs proper cooling before you should do very much else. I suggest asking technical support (perhaps you've bought a manufacturer warranty?) what to do. They will assist you with that properly.

    When you are done with that, try looking at what microsoft explains about your IDE and see if that helps:

    http://support.microsoft.com/default...pr=vst&sid=220

  7. #7
    Registered User
    Join Date
    Apr 2006
    Posts
    83
    I tried this also...but the problem is how can we get output and where?????turbo c gives a new Dos window for out put ,..but here where will be the output... i can compile... but dont know about output

  8. #8
    Registered User
    Join Date
    Apr 2006
    Posts
    83
    Quote Originally Posted by laserlight View Post
    Haven't you tried running the program?

    Incidentally, it may be better to test with something simpler, e.g.,
    Code:
    #include <stdio.h>
    
    int main(void)
    {
        printf("Hello world!");
        return 0;
    }
    when written this programme and compile in boroland c++ then i got this error msg

    -------------------Configuration: First - Win32 Debug--------------------
    Compiling...
    First.cpp
    c:\program files\microsoft visual studio\myprojects\first\first.cpp(8) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.

    First.obj - 1 error(s), 0 warning(s)

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Add
    #include "stdafx.h"
    at the first line of your source file.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Registered User
    Join Date
    Apr 2006
    Posts
    83
    Quote Originally Posted by Elysia View Post
    Add
    #include "stdafx.h"
    at the first line of your source file.
    Now that worked well...... no error..but how can i see the output???????problem stilll there??????????????????


    i think i ahve to swithc to another compiler..... suggest some easy one please

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I tried this also...but the problem is how can we get output and where?????turbo c gives a new Dos window for out put ,..but here where will be the output... i can compile... but dont know about output
    This depends on your IDE, but typically there would be some shortcut icon to run the program, a shortcut key combination, or some menu option. Alternatively, you can run your console program from a command prompt.

    when written this programme and compile in boroland c++ then i got this error msg
    And you did not get this error message when compiling the program whose code you provided earlier?

    It looks like you should disable precompiled headers.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    You just need to add "#include stdafx.h" to the beginning of your source files. No need to bother going into options and disabling precompiled headers. It's more a hassle than adding a single line of code.

    You just don't know how to actually use the IDE. It's not the IDE's fault. It's your fault.
    Common ways are add "getch()" at the end of of main. Run program with Ctrl+F5. Add a breakpoint at the end of main (F9) and run with F5.
    The last two only works with Visual Studio.

    And if you can, I do suggest you try Visual Studio 2008 Express. VC6 is old, and age is making it bad.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You just need to add "#include stdafx.h" to the beginning of your source files. No need to bother going into options and disabling precompiled headers. It's more a hassle than adding a single line of code.
    Unfortunately, precompiled headers are non-standard. You might as well disable precompiled headers, considering that this should be a one time change as well.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #14
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Perhaps your CMD window is flashing up and going away too fast for you to see it.

  15. #15
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by laserlight View Post
    Unfortunately, precompiled headers are non-standard. You might as well disable precompiled headers, considering that this should be a one time change as well.
    Even using PCH, it will still compile fine with other compilers.
    What should be disabled is Microsoft extensions. But unfortunately, their headers are so full of them it's impossible to compile code without them.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed