CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Join Date
    May 2003
    Location
    Lower mainland BC
    Posts
    11

    Question Linking error (newbie)

    this is my program :

    #include<iostream.h>

    int main()

    {
    double pi = 3.14;
    double radius;
    cout<<"Enter radius (0 to quit): ";
    cin>>radius;

    while(radius!=0) {
    cout<<"Area is: "<<radius*radius*pi<<endl;
    cout<<"Enter radius (0 to quit): ";
    }

    cout<<"Have a good day!"<<endl;
    return(0);

    }


    This is the errors generated when I try to build the program

    --------------------Configuration: review15 - Win32 Debug--------------------
    Linking...
    LINK : warning LNK4076: invalid incremental status file "Debug/review15.ilk"; linking nonincrementally
    LINK : fatal error LNK1207: incompatible PDB format in "F:\C++\CHAPTER\REVIEW\PASSWORD PROGRAM\review15\Debug\review15.pdb"; delete and rebuild
    Error executing link.exe.

    review15.exe - 1 error(s), 1 warning(s)



    I am taking a self taught C++ class in grade 12 and the teacher does not have any C++ knowledge. I am hoping someone has the time to assist me with my troubles. Thank you!
    Last edited by newborn; May 5th, 2003 at 12:17 PM.
    Ask many questions, gain much knowledge.

    Chris

  2. #2
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658
    Go under the Build menu, click "Clean" then go under Build again and do Rebuild All. That should fix you up, let us know if it does not
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  3. #3
    Join Date
    May 2003
    Location
    Lower mainland BC
    Posts
    11

    Thank you

    That worked. Thanks a lot. Ive got one more question for ya.

    My program when run displays:

    Press any key to continue

    It does not execute the way it is coded to. If you can see any obvious errors im missing, please point them out.

    Thanks for your help
    Ask many questions, gain much knowledge.

    Chris

  4. #4
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658
    The console window that runs with VC++ is not how the real console window will be. If you go to cmd.exe or command.exe (depending on which OS) and run your app that "press any key" stuff won't show up, just your regular code. That is there because normally, after running your app, the console window would shut down, which would prevent you from seeing your outputted data.

    Or are you saying that's the only thing you see?
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  5. #5
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    One side note....the usage of the old header files ('iostream.h') is depreciated...

    Almost all compilers, even those complying with ANSI standard, allow the use of the traditional header files (like iostream.h, stdlib.h, etc). Nevertheless, the ANSI standard has completely redesigned these libraries taking advantage of the template feature and following the rule to declare all the functions and variables under the namespace 'std'.

    The standard has specified new names for these "header" files, basically using the same name for C++ specific files, but without the ending '.h'. For example, 'iostream.h' becomes 'iostream'.

    If you use the ANSI-C++ compliant include files you have to bear in mind that all the functions, classes and objects will be declared under the 'std' namespace.

    Thus...for your example:
    Code:
    #include<iostream>
    
    int main()
    {
      double pi = 3.14;
      double radius;
      std::cout<<"Enter radius (0 to quit): ";
      std::cin>>radius;
    
      while(radius!=0) {
        std::cout<<"Area is: "<<radius*radius*pi<<std::endl;
        std::cout<<"Enter radius (0 to quit): ";
      }
    
      std::cout<<"Have a good day!"<<std::endl;
      return(0);
    }

  6. #6
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658
    Andreas: Sadly, most schools teach with .h for depreciated header files. In fact, I think my first c++ class in the univ 2 yrs ago even taught with it.

    I guess they don't give students credit; my guess is they don't think they'll understand namespaces and such.

    Anyway, in short, I'd say let him stick with the old .h headers because I doubt their teacher will teach them anything along those lines for a while; don't confuse the kid!
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  7. #7
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    I know that most teachers are teaching the wrong way of doing C++ programming. However, I would rather guess that it is not of the reasons you have mentioned, but rather for the simple fact that they do not know it properly themselves.

    However, this cannot be a reason that I do not show him the correct way. He should use the standard header (without .h) and learn it right from the beginning. He can then teach his teacher...

  8. #8
    Join Date
    May 2003
    Location
    Lower mainland BC
    Posts
    11
    Eli Gassert "Or are you saying that's the only thing you see?":

    That is all I see when I execute the program... its confusing me.



    Andreas,

    If i start using the std style of coding will it affect how my code runs? And secondly, if i undertake this, can you help me here and there when i need it? I really want to get into programming and learning the proper most up to date way would make me a better developer. If there is anything i need to change to use the std header files? Or will Visual C recognize them automatically?

    Thanks you guys.
    Ask many questions, gain much knowledge.

    Chris

  9. #9
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658
    Andreas. As a TA, I can sadly say that at my school it's because they don't give CS majors any credit. They teach them iostream.h and fstream.h first along with char arrays, and then in the next breath will teach <string> and using namespace std; (without telling them what using a namespace means -- they just say "you need it...").

    And if that's not pathetic enough, Drexel is NOW trying to teach people to use a derivative for AND and OR and NOT instead of using && || and !. So if(This AND That)... how pathetic

    But yeah I agree, people need to learn the right way first.

    Now back to the problem at hand

    newborn: When you run your application, you only see the press any key line? When you change your code and then hit ctrl+F5, do you see it recompile or does it just immediately run your application? I've had problems before where, if compiling from a network drive (like schools often have you do), it doesn't recognize file changes and it still uses an old version of your code.

    If you do see it recompile, then.... well then I don't know, your first cout/cin is not within any conditional block, so it should be executed regardless.
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  10. #10
    Join Date
    May 2003
    Location
    Lower mainland BC
    Posts
    11
    Eli,

    I logged onto a new computer, restarted it and opened up my progam on there. It worked fine. I guess the network was not recognizing my changes that were saved.

    Thanks for now, haha ill be back later.. theres no doubt on that one
    Ask many questions, gain much knowledge.

    Chris

  11. #11
    Join Date
    Apr 1999
    Posts
    27,449
    Originally posted by Eli Gassert
    Andreas. As a TA, I can sadly say that at my school it's because they don't give CS majors any credit. They teach them iostream.h and fstream.h first along with char arrays, and then in the next breath will teach <string> and using namespace std; (without telling them what using a namespace means -- they just say "you need it...").
    Here is what the inventor of the language has to say about teaching C++. Maybe you can get some influential C++ professors to read it.

    http://www.research.att.com/~bs/new_learning.pdf

    Basically, this hints that your teachers are teaching things backwards.
    And if that's not pathetic enough, Drexel is NOW trying to teach people to use a derivative for AND and OR and NOT instead of using && || and !. So if(This AND That)... how pathetic
    Well, and, or and not (not the capitalized versions) are accepted alternate syntax for &&, ||, and !. It is described in section 2.11 (Keywords) of the ANSI/ISO C++ standard. If you're not aware, be shocked that this code actually is standard C++:
    Code:
    int main()
    {
        bool a = true;
        bool b = false;
        if ( a and b )
        {
        }
    }
    No, do not include any headers! This won't compile with VC 6.0, but I believe it will compile with VC 7.0, and it will compile with the Comeau compiler (the most standard compiler around).

    Regards,

    Paul McKenzie

  12. #12
    Join Date
    May 2003
    Location
    Lower mainland BC
    Posts
    11
    paul,

    is it better for me to stick with the && || and !? for the "and - or - not" booleans? Im learning mainly via textbook, our school doenst have any C++ teachers, im doing the course by myself and have no set guidlines to what standard and form of C++ i must learn. I just want to learn the most efficient and widely used form of C++ and need all the input and help i can get from all of you guys!
    Last edited by newborn; May 6th, 2003 at 11:38 AM.
    Ask many questions, gain much knowledge.

    Chris

  13. #13
    Join Date
    Apr 1999
    Posts
    27,449
    Originally posted by newborn
    paul,

    is it better for me to stick with the && || and !? for the "and - or - not" booleans? Im learning mainly via textbook, our school doenst have any C++ teachers, im doing the course by myself and have no set guidlines to what standard and form of C++ i must learn. I just want to learn the most efficient and widely used form of C++ and need all the input and help i can get from all of you guys!
    Use the standard && ||, !. The other forms (and, or, not) are alternative syntax. Basically, they were invented for terminals (i.e. keyboards) that do not have '&' and '|' characters.

    Regards,

    Paul McKenzie

  14. #14
    Join Date
    May 2003
    Location
    Lower mainland BC
    Posts
    11
    Hello again. Here is a portion of the following code im working on. Its on counting and summing.

    int value;
    int numberofvalues++;
    int sumofvalues+=value;
    int loopend=0;

    cout<<"--Calculates the average and percent under 70--";
    cout<<"Enter a value: ("<<loopend<<" to quit): ";

    My question is, why do i have to use brackets around the loopend variable (the last line of my code). The syntax for that whole line doenst make sense to me. Without the textbook, i would have written it as follows:

    cout<<"Enter a value"<<loopend<<" to quit: ";

    is there a spacing issue on the output end of the program that im just not seeing?

    thanks for your time
    Ask many questions, gain much knowledge.

    Chris

  15. #15
    Join Date
    Oct 2002
    Location
    Arkansas, USA
    Posts
    189
    You dont have to use 'brackets' (I assume you mean parentheses). Your example prints them to the screen so the user would see 'Enter a value: (0 to quit):'

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured