• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Visual studio code newbie cant debug its first program

Joined
Aug 12, 2017
Messages
60 (0.02/day)
System Name FREQUENCY
Processor I5 4570 3.4 GHZ
Motherboard ASROCK Z97 ANNIVERSARY
Cooling STOCK INTEL
Memory HYPERX DDR3 1866MHZ
Video Card(s) MSI 750TI OC
Storage SAMSUNG 120GB SSD
Power Supply CORSAIR VS550
Mouse GM200 TURBOX
Keyboard CMSTORM DEV
Software WINDOWS 10
Joined
Dec 31, 2009
Messages
19,366 (3.70/day)
Benchmark Scores Faster than yours... I'd bet on it. :)
First, you should learn how to attach images to the forum instead making people click on links... Let's start with that before something more advanced. :)
 
Joined
Aug 12, 2017
Messages
60 (0.02/day)
System Name FREQUENCY
Processor I5 4570 3.4 GHZ
Motherboard ASROCK Z97 ANNIVERSARY
Cooling STOCK INTEL
Memory HYPERX DDR3 1866MHZ
Video Card(s) MSI 750TI OC
Storage SAMSUNG 120GB SSD
Power Supply CORSAIR VS550
Mouse GM200 TURBOX
Keyboard CMSTORM DEV
Software WINDOWS 10
if thats the case
 
Joined
Feb 11, 2008
Messages
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
If you are declaring your Main function as an integer, should it not have to return a value?

It has been a while since I have done C/C++, but should it not return zero at the very end to let the operating system know to stop execution?
 
Joined
Aug 18, 2017
Messages
340 (0.14/day)
It does not have to. It is a special case - if main does not return anything explicitly, it returns 0.
Remember that there is no such rule in C - main will return junk.
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
8,194 (1.49/day)
Location
Charleston, SC
System Name Tower of Power / Sechs
Processor i7 14700K / i7 5820k @ 4.5ghz
Motherboard ASUS ROG Strix Z690-A Gaming WiFi D4 / X99S GAMING 7
Cooling CM MasterLiquid ML360 Mirror ARGB Close-Loop AIO / CORSAIR Hydro Series H100i Extreme
Memory CORSAIR Vengeance LPX 32GB (2 x 16GB) DDR4 3600 / G.Skill DDR4 2800 16GB 4x4GB
Video Card(s) ASUS TUF Gaming GeForce RTX 4070 Ti / ASUS TUF Gaming GeForce RTX 3070 V2 OC Edition
Storage 4x Samsung 980 Pro 1TB M.2, 2x Crucial 1TB SSD / Samsung 870 PRO 500GB M.2
Display(s) Samsung 32" Odyssy G5 Gaming 144hz 1440p, ViewSonic 32" 72hz 1440p / 2x ViewSonic 32" 72hz 1440p
Case Phantek "400A" / Phanteks “Enthoo Pro series”
Audio Device(s) Realtek ALC4080 / Azalia Realtek ALC1150
Power Supply Corsair RM Series RM750 / Corsair CXM CX600M
Mouse Glorious Gaming Model D Wireless / Razer DeathAdder Chroma
Keyboard Glorious GMMK with box-white switches / Keychron K6 pro with blue swithes
VR HMD Quest 3 (128gb) + Rift S + HTC Vive + DK1
Software Windows 11 Pro x64 / Windows 10 Pro x64
Benchmark Scores Yes
if thats the case

You can always put your code in [code] [/code] BB Code as well.

Example:

[code]
#include <iostream>
using namespace std;

int main()
{
cout << "Hello, World!";
return 0;
}
[/code]


Adding the above will display like what's below. This will help other users when trying to debug your code or help out.

Code:
#include <iostream>
using namespace std;

int main()
{
    cout << "Hello, World!";
    return 0;
}
 
Last edited:
Joined
Feb 11, 2008
Messages
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
Code:
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string name, Lname;
    int age;

    cout << "Enter your first name:  ";
    cin >> name;

    cout << "Enter your last name:  ";
    cin >> Lname;

    cout << "Enter your age:  ";
    cin >> age;

    cout << "\n" << name << " " << Lname << " is " << age << " years old." << "\n" << "\n";

    system("pause");

    return 0;
}

I use Visual Studio 2017 in a Windows environment and I got your program to work making some minor modifications.

The biggest change was I always thought you had to include the string header whenever using strings. I also think that using cin with strings become more stable with the header included.
 
Last edited:
Joined
Aug 12, 2017
Messages
60 (0.02/day)
System Name FREQUENCY
Processor I5 4570 3.4 GHZ
Motherboard ASROCK Z97 ANNIVERSARY
Cooling STOCK INTEL
Memory HYPERX DDR3 1866MHZ
Video Card(s) MSI 750TI OC
Storage SAMSUNG 120GB SSD
Power Supply CORSAIR VS550
Mouse GM200 TURBOX
Keyboard CMSTORM DEV
Software WINDOWS 10
Thank you all for your posts. Any idea how can i fix?
upload_2017-9-25_16-39-36.png
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
8,194 (1.49/day)
Location
Charleston, SC
System Name Tower of Power / Sechs
Processor i7 14700K / i7 5820k @ 4.5ghz
Motherboard ASUS ROG Strix Z690-A Gaming WiFi D4 / X99S GAMING 7
Cooling CM MasterLiquid ML360 Mirror ARGB Close-Loop AIO / CORSAIR Hydro Series H100i Extreme
Memory CORSAIR Vengeance LPX 32GB (2 x 16GB) DDR4 3600 / G.Skill DDR4 2800 16GB 4x4GB
Video Card(s) ASUS TUF Gaming GeForce RTX 4070 Ti / ASUS TUF Gaming GeForce RTX 3070 V2 OC Edition
Storage 4x Samsung 980 Pro 1TB M.2, 2x Crucial 1TB SSD / Samsung 870 PRO 500GB M.2
Display(s) Samsung 32" Odyssy G5 Gaming 144hz 1440p, ViewSonic 32" 72hz 1440p / 2x ViewSonic 32" 72hz 1440p
Case Phantek "400A" / Phanteks “Enthoo Pro series”
Audio Device(s) Realtek ALC4080 / Azalia Realtek ALC1150
Power Supply Corsair RM Series RM750 / Corsair CXM CX600M
Mouse Glorious Gaming Model D Wireless / Razer DeathAdder Chroma
Keyboard Glorious GMMK with box-white switches / Keychron K6 pro with blue swithes
VR HMD Quest 3 (128gb) + Rift S + HTC Vive + DK1
Software Windows 11 Pro x64 / Windows 10 Pro x64
Benchmark Scores Yes
Did you check to see if the path is correct? Try opening "e:\VSCODE PROJECTS\HELLO WORLD\" to see if the HW.ccp file exists using explorer to verify.
 
Joined
Feb 11, 2008
Messages
607 (0.10/day)
Location
Omaha, Nebraska, USA
System Name Built By Me
Processor Intel Core i9 9900K @ 5.1 GHz
Motherboard Gigabyte Z390 Aorus Ultra
Cooling Custom Water Cooling - CPU Only
Memory 32GB (2 x 16) GSkill Ripjaws V DDR4
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 1TB Samsung 970 Evo NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro
Power Supply 850W Seasonic Platinum
Mouse Razer Viper V2 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
Joined
Aug 12, 2017
Messages
60 (0.02/day)
System Name FREQUENCY
Processor I5 4570 3.4 GHZ
Motherboard ASROCK Z97 ANNIVERSARY
Cooling STOCK INTEL
Memory HYPERX DDR3 1866MHZ
Video Card(s) MSI 750TI OC
Storage SAMSUNG 120GB SSD
Power Supply CORSAIR VS550
Mouse GM200 TURBOX
Keyboard CMSTORM DEV
Software WINDOWS 10
Managed to make a small progress,now i got this.
upload_2017-9-25_17-26-57.png

the code is (launch.json)
Code:
{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "E:\\VSCODE PROJECTS\\HELLO WORLD\\HW.cpp",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
}
]
}

main program
Code:
#include <iostream>
using namespace std;

int main()
{
cout << "Hello, World!";
return 0;
}
 
Top