P
priya
Hi all,
I am using strdup() in my c program..But I am having some
pr0blem while using the free() in my c code.here I am pasting the my
code.
#include <stdio.h>
#include "string.h"
int checking(char *a[20]);
void main()
{
int i;
char *bin3;
char *bin[20];
char *var[20];
var[0]="hello";
var[1]="world";
for( i=0;i<=1;i++)
{
bin3= strdup(var);
bin=bin3;
printf("\n the bin3 value is %s",bin3);
printf("\n the bin value is %s",bin);
free(bin3);
}
checking(bin);
}
int checking (char *a[20])
{
printf("\n the valus is %s %s ",a[0],a[1]);
return 0;
}
My output is
the bin3 value is hello
the bin value is world
the valus is ---------
I am not getting the final value inside checking function...
But i am getting the final output when comment the free(bin3) method.
//free(bin3)
I could not find the problem.if any one know the solution,plz let me
know.
Thanks...
I am using strdup() in my c program..But I am having some
pr0blem while using the free() in my c code.here I am pasting the my
code.
#include <stdio.h>
#include "string.h"
int checking(char *a[20]);
void main()
{
int i;
char *bin3;
char *bin[20];
char *var[20];
var[0]="hello";
var[1]="world";
for( i=0;i<=1;i++)
{
bin3= strdup(var);
bin=bin3;
printf("\n the bin3 value is %s",bin3);
printf("\n the bin value is %s",bin);
free(bin3);
}
checking(bin);
}
int checking (char *a[20])
{
printf("\n the valus is %s %s ",a[0],a[1]);
return 0;
}
My output is
the bin3 value is hello
the bin value is world
the valus is ---------
I am not getting the final value inside checking function...
But i am getting the final output when comment the free(bin3) method.
//free(bin3)
I could not find the problem.if any one know the solution,plz let me
know.
Thanks...