• 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.31/day)
Likes
6
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
#1
Joined
Dec 31, 2009
Messages
11,926 (4.01/day)
Likes
6,579
Location
Ohio
System Name Daily Driver
Processor 7960X 4.5GHz 16c/16t 1.2V
Motherboard MSI XPower Gaming Titanium
Cooling MCR320 + Kuplos Kryos NEXT CPU block
Memory GSkill Trident Z 4x8 GB DDR4 3600 MHz CL16
Video Card(s) EVGA GTX 1080 FTW3
Storage 512GB Patriot Hellfire, 512GB OCZ RD400, 640GB Caviar Black, 2TB Caviar Green
Display(s) 27" Acer Predator 144hz IPS + Yamakasi 27" 2560x1440 IPS
Case Thermaltake P5
Power Supply EVGA 750W Supernova G2
Benchmark Scores Faster than most of you! Bet on it! :)
#2
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.31/day)
Likes
6
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
#3
if thats the case
 
Joined
Feb 11, 2008
Messages
544 (0.15/day)
Likes
174
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#4
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
97 (0.51/day)
Likes
47
#5
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
6,631 (2.05/day)
Likes
3,950
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#6
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
544 (0.15/day)
Likes
174
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#7
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.31/day)
Likes
6
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
#8
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
6,631 (2.05/day)
Likes
3,950
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#9
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
544 (0.15/day)
Likes
174
Location
Lincoln, Nebraska, USA
System Name This PC
Processor Intel Core i7 2600K @ 4.8 GHz
Motherboard ASUS P8Z68 Deluxe
Cooling Custom Water Cooling - CPU Only
Memory 8GB (2 x 4GB) AData DDR3
Video Card(s) GTX 1080 TI - EVGA FTW3 - Slave BIOS
Storage Corsair Force GT 128GB / Samsung 850 Pro 512 GB
Display(s) AOC AGON AG271QG - 165 Hz - AHVA
Case Dimastech v2.5 Easy
Audio Device(s) Onboard
Power Supply Antec 1.2kW HCP
Mouse Logitech G403 - Wired
Keyboard Rosewill - MX Browns
Software Windows 10 Pro x64
#10
Joined
Aug 12, 2017
Messages
60 (0.31/day)
Likes
6
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
#11
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;
}