whats wrong with strcpy()

Posted by blacktooth on Stack Overflow See other posts from Stack Overflow or by blacktooth
Published on 2010-05-19T19:51:52Z Indexed on 2010/05/19 20:20 UTC
Read the original article Hit count: 140

Filed under:
|
|

What is wrong with strcpy() in this code?

void process_filedata(char *filename)
{
  void* content;
  const char * buffer;
  char * temp;
  char * row;
  char * col;
  int lsize,buflen,tmp,num_scan; //num_scan - number of characters scanned
  int m=0,p=0,d=0,j=0; //m - machine, p - phase, d- delimiter, j - job

  FILE *file_pointer = fopen("machinetimesnew.csv","r");

  if(file_pointer == NULL)
  {
   error_flag =  print_error("Error opening file");

   if(error_flag) exit(1);
  }
  fseek(file_pointer, 0 ,SEEK_END);
  lsize = ftell(file_pointer);
  buflen = lsize;
  rewind(file_pointer);
 // content = (char*) malloc(sizeof(char)*lsize);
  fread(content,1,lsize,file_pointer);
  buffer = (const char*) content;
  strcpy(temp,buffer);
  row = strtok(temp,"\n");
  ...............
  ...............

I am getting a segmentation fault..

© Stack Overflow or respective owner

Related posts about c

    Related posts about string