My prompt for my C++ problem is to write a program that accepts command line arguments and to print out true is the first character of the first argument is the same of the last character of the last argument. Otherwise it prints out false.So far I have the code: #include <iostream>#include <string>using namespace std;int main(int argc, char * argv[]){ bool check;for(int count=1; count < argc; count++) { //cout << argv[count] << endl; if(argv[count] ){}} //cout << "Is the first character of your first argument the same as the last character of your last argument? ";//cout << boolalpha << check << endl;return 0;} However, I am unsure on how to check the characters in argument. I am assuming that I would create a loop of some fashion that would run through each character in each string argument, but how do I check this if this would mean checking the string array locations within the pointer array ?

Question
Asked Oct 26, 2019
106 views

My prompt for my C++ problem is to write a program that accepts command line arguments and to print out true is the first character of the first argument is the same of the last character of the last argument. Otherwise it prints out false.

So far I have the code: 

#include <iostream>

#include <string>

using namespace std;

int main(int argc, char * argv[]){


bool check;
for(int count=1; count < argc; count++)
{
//cout << argv[count] << endl;
if(argv[count] ){

}

}


//cout << "Is the first character of your first argument the same as the last character of your last argument? ";
//cout << boolalpha << check << endl;
return 0;
}

 

However, I am unsure on how to check the characters in argument. I am assuming that I would create a loop of some fashion that would run through each character in each string argument, but how do I check this if this would mean checking the string array locations within the pointer array ?

check_circle

Expert Answer

star
star
star
star
star
1 Rating
Step 1
  • Create a C++ program which will shows either true or false for first and last string character.
  • Program must be executed by Command line by passing string in it. And the time argument is passed by user, then that string till space will be counted as 1st argument of pointer array ‘argv’.
  • So, for accessing first char of first argument through ‘argv’, create a new char type array ‘str’ which will concatenate its (argv’s) first argument in it (‘str’), ...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Create a new file (in Dev C++) and save it as lab7_XYZ.cpp (replace XYZ with your initials). In Lab ...

A: Code-#include&lt;iostream&gt;using namespace std; int main(){    cout&lt;&lt;"Hello\n";   int choice...

question_answer

Q: Write a program that computes the monthly net pay of the employee for a steel factory. The input for...

A: Employee’s gross salary is calculated by following formula , datatype and variables:Variables:rop= r...

question_answer

Q: Python 3.7.4: Write a loop that reads positive integers from standard input and that terminates when...

A: Following is the program code that takes input from the user all positive integer and terminates if ...

question_answer

Q: Given the information below, create the fully labeled Crow's Foot ERD using a specialization hierarc...

A: The fully labelled Crow's Foot ERD using a specialization hierarchy is given below. The ERD contain ...

question_answer

Q: Design a reasonably efficient algorithm for solving each of the following problems and determine its...

A: Algorithm to find who failed to pay telephone billFor finding who failed to pay telephone bill, firs...

question_answer

Q: Hello, I am a novice working with Java. I am creating an amortization schedule (pictured below) and ...

A: Declare and initialize two more double type variable totalamorized and lastamorized.Calculate these ...

question_answer

Q: In protocol 6, the code for frame arrival has a section used for NAKs. This section is invoked if th...

A: NAK is an acronym for Negative Acknowledgment.ACK is an acronym for Acknowledgment.

question_answer

Q: program7_2.pyThis Pthon program requires two functions. In the main function: create an empty list....

A: To write a program in python, that accepts the twelve random integers in a list, each in the range 1...

question_answer

Q: EXPLAIN ALL STEPS: Determine the output of the following Pep/9 machine language program if the input...

A: Address   Instruction(in hex)0000         D1FC15Convert the instructions into binary form-D=11011=00...