Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Without changing the source code, use gdb get the program to spit out My name is

ID: 3585009 • Letter: W

Question

Without changing the source code, use gdb

get the program to spit out My name is l33tn00b

Big thumbs up if you got it

#include <iostream>

#include <cstdlib>

#include <cstring>

// "carefully chosen to have 8 bytes so you can just fit it in there"
// l33tn00b


using namespace std;

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

long* ptr = new long;

long value = 15;

char user[20];

char dev[] = "Andy";

strncpy(user, argv[1], strlen(argv[1]));

*ptr = value;

cout << "My name is " << dev << endl;

cout << "Your name is " << user << endl;

cout << "The pointer has value " << *ptr << endl;

return 0;

}

Explanation / Answer

Hi,
Though using gdb, you can still rely on the defined functions to pritnt your output, so if you want to print a given string by gdb, you can simply use,
where string can have your desired o/p which is l33tn00b in this case
(gdb) printf "%s ", string
Thumbs up if this was helpful, otherwise let me know in comments

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote