r/Cplusplus • • 6d ago

Question Problem in running C++ codes

So i recently purchased a new laptop and when i try running the C++ code sometimes even if my code is correct the vscode doesnt execute the code.

Then I sent the screenshot to chatgpt and it said my code is correct some feature called

WINDOWS SMART APP CONTROL might be preventing it from executing the code .

But once I turn it off i can't turn it on again so what should i do??

1 Upvotes

14 comments sorted by

•

u/AutoModerator 6d ago

Thank you for your contribution to the C++ community!

As you're asking a question or seeking homework help, we would like to remind you of Rule 3 - Good Faith Help Requests & Homework.

  • When posting a question or homework help request, you must explain your good faith efforts to resolve the problem or complete the assignment on your own. Low-effort questions will be removed.
  • Members of this subreddit are happy to help give you a nudge in the right direction. However, we will not do your homework for you, make apps for you, etc.
  • Homework help posts must be flaired with Homework.

~ CPlusPlus Moderation Team


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

4

u/Business-Weather-217 5d ago

Install the penguin

1

u/Polarisu_san 6d ago

did u try running it plainly with g++ commands first?

1

u/kitsnet 5d ago

Use WSL if you can (and have enough memory for it). That's not the only possible solution, but the most promising in your case.

1

u/Heavy-Imagination525 5d ago

That is what AI said too . I am thinking of doing this This won't cause any problem in future right like something when i do other things like web dev and ml ??

1

u/kitsnet 5d ago

VS code with WSL runs your code in a Linux virtual machine (Ubuntu 26.04.1 by default as of now). This is also a fine choice for web dev and ML.

The virtual machine also provides a level of isolation, so it would be much less likely for the code that you write or for the additional packages/libraries that you install to support its development to break your Windows itself.

2

u/One_Worldliness_1130 6d ago

programing on windows can be a pain wait till you get to libraries CMake sometimes makes that easier but i found just compiling in the terminal easier on windows for the time i did use windows for it you can sometimes get windows to find the libraries that way as well good luck

cause winows wants you to use vs studio despite owning all other ide's almost its sad

1

u/KlutzyCompetition937 6d ago

Whitelist vs code in windows defender

1

u/Discordbothost 6d ago

I'd leave Smart App Control on for now. When it fails, is there an .exe at the path in launch.json's program field? If so, what exact message appears when you run that .exe?

1

u/agfitzp 6d ago

I don’t know who keeps telling the newbies to use VSCode for C++.

If you’re on Windows use Visual Studio, there’s a free version for non-commercial use.

If you’re on Linux use CLion, also a free version for non-commercial use.

1

u/Ordinary_Let8356 5d ago

Visual Studio - free download

Go to extensions and get C++ extensions.

New>cpp file ... copy your code Run it

1

u/La-ze 4d ago

This very ambiguous, can you clarify things?

Visual Studio Code ( VSC ), is a text editor.
Do you mean you're using a VSC extension, to compile & run the code for you?
Or are you trying to compile & execute the the code in the terminal?
What is Windows Smart App Control actually blocking? Is it blocking the terminal from executing the compiled C++ binary?

Turn what off? Windows Smart App Control? Why do you want to turn off the whole system and not whitelist the application?

0

u/LazySapiens 5d ago

Create a DevDrive on Windows. Use that drive for all of your codes.