Very new to C++

Hello I just registered. I am very new begginer and I'd like to learn scripting starting from the scratch. What I want to ask you is as following, what should I write to get the second text right below the 1st text. So text below text provided by two same commands (using int main). Hope you understand what I mean.

As well I would appreciate if anyone could share a link to any C++ tutorial/forum section for begginers from where I could get some basic information.

1
2
3
4
5
6
7
8
9
10
1st command:
int main()
{
    std::cout << "Hello World! This is my first project.\n";
}
2nd command:
int main()
{
    std::cout << "Welcome begginer.\n";
}.
For a C++ tutorial, see https://www.learncpp.com/

How are you running the programs? What os are you using?
Last edited on
Baky wrote:
As well I would appreciate if anyone could share a link to any C++ tutorial/forum section for begginers from where I could get some basic information.

https://www.learncpp.com/
https://www.cplusplus.com/doc/tutorial/
Last edited on
Hello Baky,

Thank you for using code tags.

It is always best to provide enough of a complete program that can be compiled and tested to demonstrate what you are trying to do.

My question would be is your posted code 2 separate programs or should it be 1 program?

Andy
I'm guessing these are 2 programs to be run one after the other with the output displayed together with nothing else between.

For windows, this would be a .bat file. Eg

mycmnd.bat
1
2
@cmnd1
@cmnd2


where cmnd1 is the 1st command .exe and cmnd2 is the 2nd command .exe
A few areas as a single program to start playing around:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>

int main()
{
    std::string name{"World"};
    std::cout << "Hello " << name << " This is my first project.\n";
    
    std::cout << "Please enter your name: ";
    std::cin >> name;
    std::cout << "Hello " << name << "! This is my first project.\n";
    
    name = "beginner";
    std::cout << "Welcome " << name << ".\n";
}


Hello World This is my first project.
Please enter your name: Rob
Hello Rob! This is my first project.
Welcome beginner.
Program ended with exit code: 0
Thank you all for your help!

@seeplus I am running/writing the scripts with Microsoft Visual Studio 2022 on my Windows 10 if that is what you are asking

@Handy Andy It is supposed to be 1 program only I guess (to run with Local windows debugger). I have no experience with coding or Visual studio - it is a blank page for me, I was just recommended to try writing/learning c++ code, and it might become interesting.

Thanks again for your instructions/tutorials @all, will be happy to work when I will have time to do so. Cheers and happy coding.
@seeplus I am running/writing the scripts with Microsoft Visual Studio 2022 on my Windows 10 if that is what you are asking


I think there is some confusion here - between a script and a program source code.

A program is not usually referred to as a script. A "script" is code written in a scripting language that is used to control another software application. So a C++ program is not called a script, but batch control would be - hence my earlier reply.

In this case, againtry's post above is more like what you want.


You might be interested in this site https://www.learncpp.com/
Topic archived. No new replies allowed.