CS计算机代考程序代写 #include

#include
#include
#include

// to permit this type of buffer-overflow attack, on Mac, (and to stick with 32-bit arch) compile with:
// gcc -O2 -m32 -fno-stack-protector -Xlinker -allow_stack_execute

void printPrefix (char* str) {
char buf[10];
char *bp = buf;

// copy str up to “.” input buf
while (*str!=’.’)
*(bp++) = *(str++);
*bp = 0;
}

// read string from standard input
void getInput (char* b) {
char* bc = b;
int n;
while ((n=fread(bc,1,1000,stdin))>0)
bc+=n;
}

void run () {
char input[1000];
puts (“Starting.”);
input[0] = ‘.’;
getInput (input);
printPrefix (input);
puts (“Done.”);
}

int main (int arc, char** argv) {
asm volatile (“andl $0xfff00000, %esp\n”);
asm volatile (“andl $0xfff00000, %ebp\n”);
run ();
_Exit (0);
}