From: faculaganymede (faculaganymede++at++yahoo.com)
Date: 02/17/2004 15:26:15
Thank you, Manuel. What does (*) do?
> char **temp[2];
> fun ((const char *(*)[2]) temp);
The compiler builds this okay, but I got run-time
errors. This is my simple program, please let me know
if you find an error:
---------------------------------------------
#include <stdio.h>
#include < stdlib.h>
#include <string.h>
void fun(const char *fnames[][2]);
int main( )
{
char **temp[2];
int n=10;
temp[0]=(char**)malloc(sizeof(char*)*n);
temp[1]=(char**)malloc(sizeof(char*)*n);
for(int i=0; i<n; i++)
{
temp[0][i]=(char*)malloc(sizeof(char)*256);
temp[1][i]=(char*)malloc(sizeof(char)*256);
strcpy(temp[0][i], "hello 1");
strcpy(temp[1][i], "hello 2");
}
fun((const char*(*)[2])temp);
}
void fun(const char *fnames[][2])
{
int n=10;
for(int i=0; i<2; i++)
{
for(int j=0; j<n; j++)
{
printf("%s\n", fnames[i][j]);
}
}
}
---------------------------------------------
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
This archive was generated by hypermail 2b29 : Tue Feb 17 2004 - 15:27:56 PST