Answer to Question #249687 in C++ for vishal

Question #249687

Command Line Argument - Print String

Write a program to accept a string as a command-line argument and print the same.

Sample Input (Command Line Argument) 1:

Programming


Sample Output 1:

Programming - Command Line Arguments

Sample Input (Command Line Argument) 2:

Arguments


Sample Output 2:

Arguments - Command Line Arguments


1
Expert's answer
2021-10-11T02:56:49-0400
//  Write a program to accept a string as a command-line argument and print the same
#include <iostream>
using namespace std;


int main(int argc, char** argv)
{
    string name;
    cout<<"Sample Input(command line): "<<endl;
    cin>>name;
    cout <<name<<" - Command Line Arguments"<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS