C++ string library not working?


#1

I’m new to coding, so I apologize if there’s some obvious piece of information you need to help me that I’m not providing.

The problem: Any attempt to declare a string data type causes my console application to be completely empty. The same code that gives me a blank screen in Atom works just fine in Visual Studio, CLion, etc–so it’s not a coding error.

The program can be as simple as a std::cout << “hello world”; and I can compile and run it and it works. But if I type string name; before the cout (and change NOTHING else), the “hello world” completely disappears. It’s baffling because everything else works perfectly. (and yes, I did remember to include the string library)

Am I the only one with this problem?


#2

Atom itself does not have any capability to compile or run code outside of packages and init.coffee. There’s a chance that the error is with the package you’re using (which you have not identified), but all those packages do is send your file off to an external binary for processing.

What happens when you open the command line and type g++? What happens when you navigate to the code folder and use g++ hello.cpp (or whatever the name is)?


#3

When I type g++ it gives me a fatal error: no input file. compilation terminated.

When I type g++ filename.cpp, it compiles an EXE file. When I run it, I get this error (screenshot included).

I tried googling it, but Stack Overflow’s solution was to use g++ instead of gcc, which I already did.

Any ideas? Did I perhaps install MinGW incorrectly?


#4

I don’t have any ideas, because this is well outside of my wheelhouse.


#5

No problem. I’ll figure it out eventually.

You had a good point about it not being an Atom issue, though. So you’ve put me at least one step closer to a solution.


#6

It’s both a positive and a negative that most issues like this don’t belong to Atom itself. On the plus side, the tools that packages use are almost always relied on and supported by much wider communities than this one editor could ever reach. On the negative side, you have to find someone who knows that interpreter or compiler and can troubleshoot it.

I’m absolutely sure that there’s someone out there using MinGW right now to compile a program with a string and having no issues with it. There’s definitely a solution, it’s just not one I have the knowledge to access.