Yet another dumb newbie question!

This is a discussion on Yet another dumb newbie question! within the C++ Programming forums, part of the General Programming Boards category; 'scuse me if this has been asked before, but I did have a look around for it! Why does VC++ ...

  1. #1
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605

    Question Yet another dumb newbie question!

    'scuse me if this has been asked before, but I did have a look around for it!

    Why does VC++ use _itoa etc whereas the ansi standard is itoa (no leading underscore)?

    Please enlighten a beginner!

    Cheers,

    Rob.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Because compiler companies frequently change certain things (funcitons, etc.). You'd be hard pressed to find a totally ANSI compliant compiler.

  3. #3
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    The standard says no such thing. itoa() is a non-standard function (there's atoi(), but not itoa()). The standard way of converting an int to a string is to either use sprintf() or a stringstream.

  4. #4
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    So...... VC uses _itoa to indicate that it's not an ansi standard function?

  5. #5
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    That may be why they've used an underscore, they do similar things with _getch(), _putch(). However the MSVC compiler will accept the function names without the underscore.

    There's also lots of other non-standard stuff (the API) that doesn't use underscores so I wouldn't rely on the absense of an underscore to mean the function's ANSI.

  6. #6
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    However the MSVC compiler will accept the function names without the underscore.
    That's when I noticed it. Tried to compile some code with Turbo C++ and it objected until I removed the underscore. Then compiled fine under VC without it.

    Many thanks.

    Rob.

  7. #7
    Registered User dirkduck's Avatar
    Join Date
    Aug 2001
    Posts
    428
    Also, MSVC++ isnt ANSI C comliant

  8. #8
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    I think you'd be hard pressed to find a compiler that was. MSVC++ 6.0 was released before there was an official C++ standard (although their next effort still isn't completely compliant).

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >You'd be hard pressed to find a totally ANSI compliant compiler.
    How true, you have to be very careful when trying to write compliant or portable code because compilers try to sneak implementation defined and nonstandard functions onto you. A copy of the ISO standard is most useful

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 05:43 AM
  2. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 09:00 AM
  3. newbie: array question :(
    By cstudent in forum C Programming
    Replies: 2
    Last Post: 04-09-2008, 07:46 AM
  4. Dumb I/O Performance Question
    By BENCHMARKMAN in forum C Programming
    Replies: 18
    Last Post: 02-24-2008, 06:26 AM
  5. dumb question...
    By Sebastiani in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 07-28-2002, 11:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21