0

I'm back with yet another segfault i can't seem to conquer.

I have figured out exactly what it is, it's something with the char* string line. I use it to break up the bytes to GET this pdf file for a school assignment.

Any and all help is appreciated!

void* consumer(void *temp)
{
int* stuff = reinterpret_cast<int*>(temp);
int x = *stuff;
char* string[];
stringstream stream1;
stringstream stream2;
int temp1=0;
int temp2=0;
int sent1=0;
int sent2=0;
ofstream fout;

strcpy(string,request); //SEGFAULT(11) ON THIS LINE, WHEN CALLING "string"
strcat(string,"Byte Range: ");
...

The complete code can be found here; https://www.dropbox.com/sh/dt90ot3z4v5nruy/1H9a5Cyb5A mgetweb.h and mgetweb.cpp

1 Answers1

1

You haven't new memory for string pointer yet, it's undefined behavior to access it.

//  char* string[]; I guess that's not what you intent to do, declaring an array of pointers?

char* string = new char[BIG_ENOUGH_SIZE];
strcpy(string, request);
billz
  • 44,644
  • 9
  • 83
  • 100