0

I tried my code in Visual studio and it doesn't give me an error, but when I tried my code on visual basic 6.0 c++ file (which should be the app required) , it gives me 2 errors

This is my code:

#include <iostream>
#include <string>
#include <limits>

int main()
{
    std::cout << "CONVERSION\n\n";
    std::cout << "Base 11 to Decimal\n";

    char ans;

    do
    {        
        std::string s;

        bool valid_input = false;
        while ( !valid_input )
        {
            std::cout << "Base 11: ";

            if ( !std::getline( std::cin, s ) ) break;

            if ( !( valid_input = s.find_first_not_of( "0123456789aA" ) == std::string::npos ) )
            {                
                std::cout << "Invalid Input\n\n";
            }
        }

        if ( !valid_input )
        {
            std::cout << "See you later!" << std::endl;
            break;
        }

        unsigned long value = std::stoul( s, nullptr, 11 );

        std::cout << "Decimal: " << value << "\n\n";

        std::cout << "Do you want to continue (Y/N)? ";
        std::cin >> ans;
        std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
    } while ( ans == 'y' && ans == 'Y' );

    std::cout <<"Name:\tXXXXXXXX\n";
    std::cout <<"Course:\tXXXXXXXX\n";
    std::cout <<"Section:\tXXXXXXXX\n";
    std::cout <<"Schedule:\tXXXXXXXX\n";
    std::cout <<"Professor:\tXXXXXXXX\n";

    return 0;
}

and these are the errors

enter image description here

Any alternative codes ? Codes in my brain are limited, Any help would be much appreciated!

Cheers and hth. - Alf
  • 142,714
  • 15
  • 209
  • 331
  • 3
    Visual Studio 6.0 is old, *ancient* even. It was released in 1998 which is the same year C++ was first standardized. That means it doesn't really have all of standard C++ since it was barely invented by then. Is there a reason you use such an ancient version when you can get Visual Studio Express 2015 for free? – Some programmer dude Mar 02 '16 at 12:46
  • 1
    The code you pasted says "stoul", the picture says "strtoul". `strtoul` is declared in ``, or ``. And `nullptr` is C++11; use `NULL`. – molbdnilo Mar 02 '16 at 12:57
  • @molbdnilo should i put #include ? – Jet Mortola Joseph Mar 02 '16 at 13:00
  • Please include your error message(s) in the body of the post, not hidden in an unreadable picture. The latter doesn't index very well for searching! You also need to provide your input file (or, better, make your program self-contained) in order for it to be a [Minimal, Complete and Verifiable Example](/help/mcve). – Toby Speight Mar 02 '16 at 13:03
  • @JetMortolaJoseph Yes. And pass `s.c_str()`. – molbdnilo Mar 02 '16 at 13:04
  • @molbdnilo where should i put that code ? – Jet Mortola Joseph Mar 02 '16 at 13:05
  • @TobySpeight sorry for that – Jet Mortola Joseph Mar 02 '16 at 13:05
  • Beware that if this is homework, you may be expected to perform the base conversion yourself and not rely on the library. – molbdnilo Mar 02 '16 at 13:06
  • @JetMortolaJoseph I'm positive that you can figure it out on your own if you consider which line of code this question is about. – molbdnilo Mar 02 '16 at 13:08
  • It's not a homework, Im studying these codes in advance so I'll be ready for my programming language next semester – Jet Mortola Joseph Mar 02 '16 at 13:10

0 Answers0