Question

In: Computer Science

This is an assignment done using the terminal of linux. In this assignment, you will •...

This is an assignment done using the terminal of linux.

In this assignment, you will

• use make to modify a c++ program and

• gdb a debugging tool.

Part 1

From the course website (or the departmental dropbox) download the program source files for the project myname.

Part 2: myname program (5 points)

1. Using your favorite text editor, modify the source code to print out your name instead of mine when the binary file is executed. Hint: YOU ARE NOT ”THOMAS THE TANK ENGINE”

2. Modify the makefile to include a rule that creates a backup of the source files, makefile, and readme in an archive directory in your home directory structure.

Submit a compressed, archived tar file [yourUserID].assignment4_1.tar.[Z,gz] with your modified source code.

3. Use the gdb debugger to step through the program. Check to ensure the Makefile is modified to allow for debugging. Submit a text file [yourUserID].assignment4_2.txt containing the gdb output for the following sequence of commands:

gdb myname

start

step [issue this command until you get the “program exited normally” message]

quit

Submission This time, there should be two files that you are uploading

[yourUserID].assingment4_1.tar.[Z,gz] and [yourUserID].assingment4_2.txt

• When you have finished, submit the files using the departmental dropbox.

Here are the contents of CSCE215 directory that contains the program and files associated with it:

main.cpp

#include <iostream>
#include <string>
using namespace std;
#include "name.h"

int main () {
        name myName;

        myName.SetLast(LAST);
        myName.SetMiddle(MI);
        myName.SetFirst(FIRST);

        cout <<"My name is: ";
        myName.PrintFirst();
        myName.PrintMiddle();
        myName.PrintLast();
  
        return 0;
}

Makefile

# makefile to build a program

# program depends on components: name and main
myname:      main.o name.o
   g++ -g main.o name.o -o myname

# name.cpp has it's own header file
name.o:        name.cpp name.h
   g++ -c -g name.cpp

# main.cpp also uses the header file name.h
main.o:           main.cpp name.h
   g++ -c -g main.cpp

clean:
   /bin/rm -f myname *.o

name.cpp

#include <iostream>
#include <string>
using namespace std;
#include "name.h"

void name::GetFirst(string str) {
   str=first;
}

void name::SetFirst(string str) {
   first=str;
}

void name::GetMiddle(string str) {
   str=middle;
}

void name::SetMiddle(string str) {
   middle=str;
}

void name::GetLast(string str) {
   str=last;
}

void name::SetLast(string str) {
   last=str;
}

void name::PrintLast() {
   cout << last << "\n";
}
void name::PrintMiddle() {
        cout << middle;
}
void name::PrintFirst() {
        cout << first;
}

name.h

#define LAST   "tankengine"
#define MI   "the "
#define FIRST   "thomas "

class name {

   private:
   string first;
   string middle;
   string last;
  
   public:
   void SetFirst(string str);
   void GetFirst(string str);
  
   void SetMiddle(string str);
   void GetMiddle(string str);
  
   void SetLast(string str);
   void GetLast(string str);

   void PrintLast();
   void PrintMiddle();
   void PrintFirst();
  
};

readme

/*
Copyright: 2005, All rights reserved.
Program: myname
Version: 1.1
Created: 9/6/05
Revised: 1/22/09
Files: name.cpp, name.h, main.cpp, Makefile
Programmer: Patrick O'Keefe who gratefully acknowledges Dr. Jason Bakos's kind assistance.
Course: CSCE-215
Assignment: Class Project
Compiler: GNU Gcc version 4.2.3
Target: Linux

Description:

This program attempts string assigment. and other stuff....

Revisions:

There have been no major revisions of this program.

Constants and Variables:

See code for constant and variable descriptions.
or
you could put that kind of info here. Like:
   FIRST -> your first name
   MIDDLE -> ditto
   LAST -> and ditto.
ok here is a change.

ALL OF THOSE FILES ARE LOCATED IN A DIRECTORY /CSCE215


Solutions

Expert Solution

//main.cpp
#include <iostream>
#include <string>
using namespace std;
#include "name.h"

int main () {
name myName;

myName.SetLast(LAST);
myName.SetMiddle(MI);
myName.SetFirst(FIRST);

cout <<"My name is: ";
myName.PrintFirst();
myName.PrintMiddle();
myName.PrintLast();
  
return 0;
}

====================================================================

//name.cpp

#include <iostream>
#include <string>
using namespace std;
#include "name.h"

void name::GetFirst(string str) {
   str=first;
}

void name::SetFirst(string str) {
   first=str;
}

void name::GetMiddle(string str) {
   str=middle;
}

void name::SetMiddle(string str) {
   middle=str;
}

void name::GetLast(string str) {
   str=last;
}

void name::SetLast(string str) {
   last=str;
}

void name::PrintLast() {
   cout << last << "\n";
}
void name::PrintMiddle() {
cout << middle;
}
void name::PrintFirst() {
cout << first;
}

===================================================================

//name.h
#define LAST   "grabasandwhich"
#define MI   "G."
#define FIRST   "bobby "

class name {

   private:
   string first;
   string middle;
   string last;
  
   public:
   void SetFirst(string str);
   void GetFirst(string str);
  
   void SetMiddle(string str);
   void GetMiddle(string str);
  
   void SetLast(string str);
   void GetLast(string str);

   void PrintLast();
   void PrintMiddle();
   void PrintFirst();
  
};

===================================================================

sample output:


Related Solutions

In Linux Terminal 1. Give a command using find to search from the root directory the...
In Linux Terminal 1. Give a command using find to search from the root directory the file program.f and redirect any errors to the file myerrors.txt 2. Give a command for finding files having the letters index as the beginning of the file name and located in your home directory (provide the absolute path) 3. Give a command for finding within a directory called /mp3collection, only those mp3 files that have a size less than 5000 Kilobytes (< 5MB). 4....
Please write in C using linux or unix.please include pictures of the terminal output. Write a...
Please write in C using linux or unix.please include pictures of the terminal output. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the...
using 2 semaphores and 1 mutex: (solve in simple c++ language for linux terminal and add...
using 2 semaphores and 1 mutex: (solve in simple c++ language for linux terminal and add comments please) The barber shop has one barber (a thread), one barber chair, and n chairs for waiting customers (semaphore), if any, to sit on. If there are no customers (each customer is a thread) present, the barber sits down in the barber chair and falls asleep. When a customer arrives, he has to wake up the sleeping barber. If additional customers arrive while...
Assignment 1 – Writing a Linux Utility Program Instructions For this programming assignment you are going...
Assignment 1 – Writing a Linux Utility Program Instructions For this programming assignment you are going to implement a simple C version of the UNIX cat program called lolcat. The cat program allows you to display the contents of one or more text files. The lolcat program will only display one file. The correct usage of your program should be to execute it on the command line with a single command line argument consisting of the name you want to...
Write a shell program named HELLO2(this should be done in linux, using bash) Consider files in...
Write a shell program named HELLO2(this should be done in linux, using bash) Consider files in the current directory whose names end in 't' or 'z'. For such files only, your program should list certain LINES of the file(s). These lines are those that have at least 4 x's somewhere in the line. Note that the x's may be upper- or lower-case, and may be separated by other characters; so the following 3 lines DO match: XXxX and more things...
***************************************************** * USE UBUNTU (Linux) TERMINAL MODE COMMANDS ONLY * * DO NOT USE ANY EDITORS...
***************************************************** * USE UBUNTU (Linux) TERMINAL MODE COMMANDS ONLY * * DO NOT USE ANY EDITORS TO CREATE THIS PROGRAM * ***************************************************** 1) Create a file called lastNameFirstNameInitialpgm3.sh ex: robinsonMpgm1.sh 2) Append to the above file the necessary commands that when this file is executed it will display the following: - Using your own set of multi-line comments enter your program identification as described in the Syllabus, example: <<ID ************************************************** Author : Your Name Course : Course Name and Times...
Assignment Direction: Complete Part I of this assignment first, if you have not done so, because...
Assignment Direction: Complete Part I of this assignment first, if you have not done so, because it provides guided practice on questions similar to the questions in Part II here. Check out the “Important Resources and Assignment Guides” in the Modules section on Canvas to see how to properly show your math work. There are also examples of the APA-style tables and graphs (figures) for your reference. Your submitted assignment must be in Word format, with a clear answer typed...
I am doing this assignment using Kali Linux (COMPUTER SECURITY) I need to use crunch to...
I am doing this assignment using Kali Linux (COMPUTER SECURITY) I need to use crunch to generate all words which start with a lowercase letter, and then "YOURNAME(uppercase letter)", and then end with 2 digits. (e.g., "aIMAN23") I just need the screenshot of the crunch commands to follow. Using John the Ripper (In Kali Linux) I need the john command so I can use to Break test user's password: test:$6$fFEVS9TQoNU/aQsm$hxv5R1cSxwENUcdjxlI9WwbF8F3uruxAlDUf0vXaOAJRZnWhxr7zzLlFNJPGvc1pTdVV.lsuQkQh3mSjpy6SG/:18535:::::: I just need the screenshot to follow.
LAB 7.1 MANAGING USER ACCOUNTS STEP 1. Open a terminal window in linux.                               &n
LAB 7.1 MANAGING USER ACCOUNTS STEP 1. Open a terminal window in linux.                                         STEP 2. Execute the correct command to display user account information (including the login shell and home directory) for the bin account.                                         STEP 3. Execute the correct command to display user password information (including the encrypted password and password aging) for the bin account.                                         STEP 4. The command in step 3 should have failed. Execute the correct su command to change your account so...
Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal...
Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal window.             a) list the current directory contents with the long format             b) print the name of the working directory             c) change directory to the root directory             d) change the permissions of file "myfile" (owned by yourself) so that (1)you can read/write, but cannot execute; (2) all other users cannot read/write/execute this file.             e) make a new directory called “mydir”
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT