This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug with strcat


This code produces an access violation. Commenting out the arr[] it works fine. Leaving the arr[] and commenting out the strcat works too.
Anyway on a Linux with GCC 3.4.2 it works as it is presented here without problems


#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{

int arr[] = {1,2,3,4,5};

       char *buf = (char *) malloc (80);
       if (buf == ((void *)0))
               printf("LKD error: Not enough memory\n");

int a = 20;

{char tempBuffer[80];int bsize;snprintf (tempBuffer,80, "Ivan %d", a );bsize += strlen(tempBuffer) + 1; buf = (char *) realloc (buf, bsize); strcat(buf, tempBuffer);}

return 0;
}

_________________________________________________________________
Charla con tus amigos en línea mediante MSN Messenger: http://messenger.latam.msn.com/



-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]