-3

I downloaded Microsoft Visual C from the Internet, and started to code. Issued some commands, but it is not working and I am confused.

When I entered the C expression gets(Name); the compiler said the function is unidentified, why??? How is this compiler different from a regular C++ compiler? Why did it not find the command? I have declared the libraries: <windows.h>, <stdio.h> and <math.h>. Not sure what is wrong.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
stfark
  • 1
  • 1
  • 3
    Please read [ask] with a [mcve]. Note that `gets` is `std::gets` and requires the header `` see: https://en.cppreference.com/w/cpp/io/c/gets Note also that this function was removed in C++14, but can be used with C++11. – Richard Critten Jul 01 '20 at 21:11
  • *When I entered the c expression gets(Name)* -- Whatever book you are learning from that says to use `gets`, get rid of it, quick. – PaulMcKenzie Jul 01 '20 at 21:14
  • 2
    @RichardCritten `gets()` is [`std::gets()`](https://en.cppreference.com/w/cpp/io/c/gets) only if you do include ``. If you include `` instead then it is just plain [`gets()`](https://en.cppreference.com/w/c/io/gets). – Remy Lebeau Jul 01 '20 at 21:16
  • 2
    _I downloaded Microsoft Visual C from the Internet, and started to code_ Have you read any [books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)? – Paul Sanders Jul 01 '20 at 21:22
  • Anyone: As mentioned above, have been using Microsoft C++ 6.0, I know it is out dated but after getting a new computer, the original software will not load as was developed for a 32 bit Op Sys and this one is 64 bit. Whether that makes a difference or not, the software will not load. Therefore, downloaded the Microsoft Visual C software from internet and it is based on C# with many differences from C++ 6.0. With this info, what is a good document to get the will list all of the C# commands, functions, examples, etc. Any advise will be helpful. Thanks in advance, Sid Kraft – stfark Jul 01 '20 at 23:10
  • 1
    Modern Visual Studio supports both C++ and C#. They're different languages. Either you're writing code in one or the other. Also, both C++ and Visual Studio have evolved since VS 6.0. Back then VS didn't support a proper C++ standard. Now it does. So many differences in what will compile in newer VS compared to older are simply due to it complying to the proper modern C++ standard. – TheUndeadFish Jul 01 '20 at 23:28
  • @stfark *Therefore, downloaded the Microsoft Visual C software* -- Are you allowed to do that, even with the old versions? The first downloadable, free versions I know of are the Visual Studio Community Editions of 2015 and above. The older versions are not public domain and still owned by Microsoft, from what I remember. If you want an older compiler, you had to get an MSDN subscription. – PaulMcKenzie Jul 02 '20 at 00:00
  • Have Visual C loaded, how do I start process or How do I start debugger, step into? When I execute the step into with the debugger, system says program no loaded, not available??? is there something missing or? – stfark Jul 05 '20 at 22:16

1 Answers1

0

std::gets was deprecated in C++11 and removed from C++14. It was defined in cstdio. If you're learning a new language you should be learning the latest and greatest version. C++17 would be the most common version to learn at this time.

Please try this code which would be basically equivalent to what you were trying to use and doesn't rely on any outdated stuff:

#include <iostream>
#include <windows.h>

int main()
{
    std::string name;
    
    std::cin >> name;

    std::cout << name;

    return 0;
}

You should be using Visual Studio Community 2019, or whatever the latest version is when you read this answer. There are no issues with developing generic x86 software on a x64 system.

Microsoft Visual C++ is not based on C#.

GuidedHacking
  • 3,628
  • 1
  • 9
  • 59
  • If Microsoft Visual C 19 is not based on C# will it still accept Microsoft C++ 6.0 commands and C# commands? – stfark Jul 02 '20 at 22:09
  • Ran the program as above, got the following errors: MSB6006 CL.exe exited with code 2 and DB016 'Z1" and 'GY-' command lines incompatible???? – stfark Jul 02 '20 at 22:50