See subject: how do I calloc (and free the memory, if that's not
free(my_bytes); ) this?
TIA!
Nov 13 '05
43 3402
Giuseppe <gi******@giuse ppe.wwwew> wrote: On Sun, 06 Jul 2003 14:26:30 GMT, Al Bowers <xa*@abowers.co mbase.com> wrote:M-One wrote: > Question 6.16 discuss this topic. > http://www.eskimo.com/~scs/C-faq/q6.16.html [...]
#define R return
return 0;
What kind of game are you playing? "How inconsiquent can you get?"
You're close to win the prize.
--
Z (Zo**********@d aimlerchrysler. com)
"LISP is worth learning for the profound enlightenment experience
you will have when you finally get it; that experience will make you
a better programmer for the rest of your days." -- Eric S. Raymond
#include <stdio.h>
#include <stdlib.h>
#define P printf
#define R return
#define F for
#define NROWS 256
#define NCOLUMNS 256
typedef struct ARRAY{
unsigned char** a;
size_t nrows;
size_t nco;
}ARRAY;
int resizeARRAY(ARR AY** p, size_t nrows, size_t ncolumns);
void freeARRAY(ARRAY *p);
void freeARRAY_1(ARR AY *p);
ARRAY* somma(ARRAY* r, ARRAY* a, ARRAY* b);
void stampa(ARRAY* a);
int main(void)
{
ARRAY *r=0, *a=0, *b=0;
if(resizeARRAY( &r, 3, 3) * resizeARRAY(&a, 3, 3)*
resizeARRAY(&b, 3, 3)!= 0 )
{
a->a[0][0]= 9; a->a[0][1]=15; a->a[0][2]=20;
a->a[1][0]=10; a->a[1][1]=14; a->a[1][2]=20;
a->a[2][0]=10; a->a[2][1]=15; a->a[2][2]=19;
b->a[0][0]=1 ; b->a[0][1]=1 ; b->a[0][2]=2 ;
b->a[1][0]=1 ; b->a[1][1]=1 ; b->a[1][2]=2 ;
b->a[2][0]=1 ; b->a[2][1]=1 ; b->a[2][2]=2 ;
if(somma(r, a, b));
{stampa(a);P("+ \n"); stampa(b);P("== \n"); stampa(r);}
}
freeARRAY_1(r); freeARRAY_1(a); freeARRAY_1(b);
R 0;
}
void stampa(ARRAY* a)
{ size_t i, j;
if(!a) R ;
F( i=0; i<a->nrows; ++i )
{P("\n");
F( j=0; j<a->nco ; ++j)
P("%3u ", (unsigned) a->a[i][j]);
}
P("\n");
}
ARRAY* somma(ARRAY* r, ARRAY* a, ARRAY* b)
{
size_t i, j;
unsigned char h;
if(r->nrows!=a->nrows||r->nrows!=b->nrows||a->nrows!=b->nrows)
R 0;
if(r->nco!=a->nco||r->nco!=b->nco||a->nco!=b->nco)
R 0;
F( i=0; i< r->nrows; ++i)
F( j=0; j< r->nco; ++j)
{h= a->a[i][j] + b->a[i][j];
if( h< a->a[i][j] || h< b->a[i][j] )
R 0;
r->a[i][j]=h;
}
R r;
}
int resizeARRAY(ARR AY** p, size_t nrows, size_t ncolumns)
{ size_t i, j=0;
unsigned char **temp;
if(*p==0) {if( (*p=malloc(size of(**p)))==0 )
R 0;
j=1;
}
if( (temp=realloc( (*p)->a, nrows * sizeof(*temp) )) == NULL )
{if(j) free( *p );
R 0;
}
(*p)->a=temp;
for( i=0; i<nrows; i++ )
{(*p)->a[i]=malloc( ncolumns * sizeof( *((*p)->a[i]) ) );
if((*p)->a[i] == NULL)
{if(i)
F( --i; i!=0; --i)
free( (*p)->a[i] );
free( (*p)->a[0] );
free( (*p)->a );
if(j) free( *p );
R 0;
}
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns;
return i; /* Ritorna il numero di colonne allocate; */
}
void freeARRAY(ARRAY * p)
{ size_t i;
if(!p) R;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
p->a = 0;
p->nco = 0;
p->nrows = 0;
}
void freeARRAY_1(ARR AY* p)
{ size_t i;
if(!p) R;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
free(p);
}
On Tue, 08 Jul 2003 07:49:02 GMT, gi******@giusep pe.wwwew (Giuseppe)
wrote: int resizeARRAY(ARR AY** p, size_t nrows, size_t ncolumns) { size_t i, j=0; unsigned char **temp;
if(*p==0) {if( (*p=malloc(size of(**p)))==0 ) R 0; j=1; } if( (temp=realloc( (*p)->a, nrows * sizeof(*temp) )) == NULL ) {if(j) free( *p ); *p=0;
if(j){free(*p); *p=0; } R 0; }
(*p)->a=temp; for( i=0; i<nrows; i++ ) {(*p)->a[i]=malloc( ncolumns * sizeof( *((*p)->a[i]) ) ); if((*p)->a[i] == NULL) {if(i) F( --i; i!=0; --i) free( (*p)->a[i] ); free( (*p)->a[0] ); free( (*p)->a ); if(j) {free( *p ); *p=0; } R 0; } } (*p)->nrows = nrows ; (*p)->nco = ncolumns; return i; /* Ritorna il numero di colonne allocate; */ }
Giuseppe wrote: #include <stdio.h> #include <stdlib.h>
Your program crashes on my machine.
--
pete
#include <stdio.h>
#include <stdlib.h>
#define P printf
#define R return
#define F for
#define NROWS 256
#define NCOLUMNS 256
typedef struct ARRAY{
unsigned char** a;
size_t nrows;
size_t nco;
}ARRAY;
int creaARRAY(ARRAY ** p, size_t nrows, size_t ncolumns);
int rszARRAY (ARRAY** p, size_t nrows, size_t ncolumns);
void freeARRAY (ARRAY* p);
void freeARRAY_d(ARR AY* p);
ARRAY* somma (ARRAY* r, ARRAY* a, ARRAY* b);
void stampa (ARRAY* a);
int main(void)
{
ARRAY my={NULL, 0, 0}, *r=0, *a=0, *b=0, *mmy=&my;
if(creaARRAY(&m my, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.arra y1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mm y, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.arra y1[255+100][255+100] = \'%c\'\n",
my.a[255+100][255+100]);
}
freeARRAY(&my);
if(creaARRAY(&r , 3, 3) * creaARRAY(&a, 3, 3)*
creaARRAY(&b, 3, 3)!= 0 )
{
a->a[0][0]= 9; a->a[0][1]=15; a->a[0][2]=20;
a->a[1][0]=10; a->a[1][1]=14; a->a[1][2]=20;
a->a[2][0]=10; a->a[2][1]=15; a->a[2][2]=19;
b->a[0][0]=1 ; b->a[0][1]=1 ; b->a[0][2]=2 ;
b->a[1][0]=1 ; b->a[1][1]=1 ; b->a[1][2]=2 ;
b->a[2][0]=1 ; b->a[2][1]=1 ; b->a[2][2]=2 ;
if(somma(r, a, b));
{stampa(a);P("+ \n"); stampa(b);P("== \n"); stampa(r);}
}
if(rszARRAY(&r, NROWS, NCOLUMNS))
{(*r).a[255][255] = 'c';
printf("my.arra y1[255][255] = \'%c\'\n", (*r).a[255][255]);
}
freeARRAY_d(r); freeARRAY_d(a); freeARRAY_d(b);
R 0;
}
void stampa(ARRAY* a)
{ size_t i, j;
if(!a || a->a==0) R ;
F( i=0; i<a->nrows; ++i )
{P("\n");
F( j=0; j<a->nco ; ++j)
P("%3u ", (unsigned) a->a[i][j]);
}
P("\n");
}
ARRAY* somma(ARRAY* r, ARRAY* a, ARRAY* b)
{
size_t i, j;
unsigned char h;
if(r==0||a==0|| b==0||r->a==0||a->a==0||b->a==0)
R 0;
if(r->nrows!=a->nrows||r->nrows!=b->nrows||a->nrows!=b->nrows)
R 0;
if(r->nco!=a->nco||r->nco!=b->nco||a->nco!=b->nco)
R 0;
F( i=0; i< r->nrows; ++i)
F( j=0; j< r->nco; ++j)
{h = a->a[i][j] + b->a[i][j];
if( h< a->a[i][j] || h< b->a[i][j] )
R 0;
r->a[i][j]=h;
}
R r;
}
int creaARRAY(ARRAY ** p, size_t nrows, size_t ncolumns)
{ size_t i, j=0;
if(p==0) R 0;
if(*p==0) {if( (*p=malloc(size of(**p)))==0 )
R 0;
j=1;
}
if( ( (*p)->a = malloc(nrows * sizeof( *((*p)->a)) ) ) == NULL )
{if(j) {free( *p ); *p=0;}
else {(*p)->nrows=0; (*p)->nco=0;}
R 0;
}
for( i=0; i<nrows; i++ )
{(*p)->a[i]=malloc( ncolumns * sizeof( *((*p)->a[i]) ) );
if((*p)->a[i] == NULL)
{if(i)
F( --i; i!=0; --i)
free( (*p)->a[i] );
free( (*p)->a[0] );
if(j) {free( *p ); *p=0; }
else {(*p)->nrows=0; (*p)->nco=0;}
R 0;
}
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns;
return i; /* Ritorna il numero di colonne allocate; */
}
/* Da usarsi a matrice già creata */
int rszARRAY(ARRAY* * p, size_t nrows, size_t ncolumns)
{ size_t i;
unsigned char **temp, *tmp;
if( p==0 || *p==0 )
R 0;
if( (temp= realloc( (*p)->a, nrows * sizeof *temp ) )== NULL )
R 0;
(*p)->a=temp;
for( i=0; i<nrows; i++ )
{if( i >= (*p)->nrows )
(*p)->a[i]=0; /* non c'è un puntatore risultato di malloc */
if(( tmp=realloc((*p )->a[i], ncolumns * sizeof *tmp ) )==NULL)
{
if(i)
F( --i; i!=0; --i)
free( (*p)->a[i] );
free( (*p)->a[0] );
(*p)->nrows = 0;
(*p)->nco = 0;
R 0;
}
else (*p)->a[i]=tmp;
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns; /* nuove righe e colonne */
return i; /* Ritorna il numero di colonne allocate; */
}
void freeARRAY(ARRAY * p)
{ size_t i;
if(!p) R;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
p->a = 0;
p->nco = 0;
p->nrows = 0;
}
void freeARRAY_d(ARR AY* p)
{ size_t i;
if(!p) R;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
free(p);
}
______________
C:\NG1>mat1
my.array1[255][255] = 'c'
my.array1[255+100][255+100] = 'c'
9 15 20
10 14 20
10 15 19
+
1 1 2
1 1 2
1 1 2
==
10 16 22
11 15 22
11 16 21
my.array1[255][255] = 'c'
pete <pf*****@mindsp ring.com> wrote: Giuseppe wrote: #include <stdio.h> #include <stdlib.h>
Your program crashes on my machine.
You're surprised? ;-)
Richard
Giuseppe wrote: #include <stdio.h> #include <stdlib.h> #define P printf #define R return #define F for
You're missing
#define I if
#define II int
#define V void
#define S *
#define T typedef
:-)
Tom
On Tue, 08 Jul 2003 12:45:23 GMT, gi******@giusep pe.wwwew (Giuseppe)
wrote:
Due errori #include <stdio.h>
Ho fatto una compilazione con gcc e in questa linea risulta un
carattere non normale-return alla fine
#include <stdlib.h> #define P printf #define R return #define F for
#define NROWS 256 #define NCOLUMNS 256
typedef struct ARRAY{ unsigned char** a; size_t nrows; size_t nco; }ARRAY;
int creaARRAY(ARRAY ** p, size_t nrows, size_t ncolumns); int rszARRAY (ARRAY** p, size_t nrows, size_t ncolumns); void freeARRAY (ARRAY* p); void freeARRAY_d(ARR AY* p); ARRAY* somma (ARRAY* r, ARRAY* a, ARRAY* b); void stampa (ARRAY* a);
int main(void) { ARRAY my={NULL, 0, 0}, *r=0, *a=0, *b=0, *mmy=&my;
if(creaARRAY(&m my, NROWS, NCOLUMNS)) {my.a[255][255] = 'c'; printf("my.arra y1[255][255] = \'%c\'\n", my.a[255][255]); }
if(rszARRAY(&mm y, NROWS+100, NCOLUMNS+100)) {my.a[255+100][255+100] = 'c'; printf("my.arra y1[255+100][255+100] = \'%c\'\n", my.a[255+100][255+100]); } freeARRAY(&my);
if(creaARRAY(&r , 3, 3) * creaARRAY(&a, 3, 3)* creaARRAY(&b, 3, 3)!= 0 ) { a->a[0][0]= 9; a->a[0][1]=15; a->a[0][2]=20; a->a[1][0]=10; a->a[1][1]=14; a->a[1][2]=20; a->a[2][0]=10; a->a[2][1]=15; a->a[2][2]=19;
b->a[0][0]=1 ; b->a[0][1]=1 ; b->a[0][2]=2 ; b->a[1][0]=1 ; b->a[1][1]=1 ; b->a[1][2]=2 ; b->a[2][0]=1 ; b->a[2][1]=1 ; b->a[2][2]=2 ; if(somma(r, a, b));
qui c'è un ; di troppo
{stampa(a);P("+ \n"); stampa(b);P("== \n"); stampa(r);}
Dubito che qualcuno possa trovare un errore degno di nota (sono
fortunato?)
Saluti
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define P printf
#define R return
#define F for
#define NROWS 256
#define NCOLUMNS 256
typedef struct ARRAY{
unsigned char** a;
size_t nrows;
size_t nco;
}ARRAY;
int creaARRAY (ARRAY** p, size_t nrows, size_t ncolumns);
int rszARRAY (ARRAY** p, size_t nrows, size_t ncolumns);
void freeARRAY (ARRAY* p);
void freeARRAY_d(ARR AY** p);
ARRAY* somma (ARRAY* r, ARRAY* a, ARRAY* b);
void stampa (ARRAY* a);
int main(void)
{ size_t i, j, h;
ARRAY my={NULL, 0, 0}, *r=0, *a=0, *b=0, *mmy=&my;
srand((unsigned )time(0));
if(creaARRAY(&m my, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.arra y1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mm y, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.arra y1[255+100][255+100] = \'%c\'\n",
my.a[255+100][255+100]);
}
freeARRAY(&my);
F(h=0; h<1000; ++h)
{if(creaARRAY(& r, 3, 3) * creaARRAY(&a, 3, 3)*
creaARRAY(&b, 3, 3)!= 0 )
{F(i=0; i<3; ++i)
F(j=0; j<3; ++j)
a->a[i][j]= rand()%100;
F(i=0; i<3; ++i)
F(j=0; j<3; ++j)
b->a[i][j]= rand()%100;
if(somma(r, a, b))
{stampa(a);P("+ \n"); stampa(b);P("== \n"); stampa(r);}
}
freeARRAY_d(&r) ; freeARRAY_d(&a) ; freeARRAY_d(&b) ;
}
R 0;
}
void stampa(ARRAY* a)
{ size_t i, j;
if(!a) R ;
F( i=0; i<a->nrows; ++i )
{P("\n");
F( j=0; j<a->nco ; ++j)
P("%3u ", (unsigned) a->a[i][j]);
}
P("\n");
}
ARRAY* somma(ARRAY* r, ARRAY* a, ARRAY* b)
{
size_t i, j;
unsigned char h;
if(r==0||a==0|| b==0|| r->a==0||a->a==0||b->a==0)
R 0;
if(r->nrows!=a->nrows||r->nrows!=b->nrows||a->nrows!=b->nrows)
R 0;
if(r->nco!=a->nco||r->nco!=b->nco||a->nco!=b->nco)
R 0;
F( i=0; i< r->nrows; ++i)
F( j=0; j< r->nco; ++j)
{h=a->a[i][j]+b->a[i][j];
if( h< a->a[i][j] || h< b->a[i][j] )
R 0;
r->a[i][j]=h;
}
R r;
}
int creaARRAY(ARRAY ** p, size_t nrows, size_t ncolumns)
{ size_t i, j=0;
if(p==0) R 0;
if(*p==0) {if( (*p=malloc(size of(**p)))==0 )
R 0;
j=1;
}
if( ( (*p)->a = malloc(nrows * sizeof( *((*p)->a)) ) ) == NULL )
{if(j) {free( *p ); *p=0;}
else {(*p)->nrows=0; (*p)->nco=0;}
R 0;
}
for( i=0; i<nrows; i++ )
{(*p)->a[i]=malloc( ncolumns * sizeof( *((*p)->a[i]) ) );
if((*p)->a[i] == NULL)
{if(i)
F( --i; i!=0; --i)
free( (*p)->a[i] );
free( (*p)->a[0] );
free( (*p)->a ); /* Libera il massimo che può */
if(j) {free( *p ); *p=0; }
else {(*p)->a=0; (*p)->nrows=0; (*p)->nco=0;}
R 0;
}
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns;
return i; /* Ritorna il numero di colonne allocate; */
}
/* Da usarsi a matrice già creata */
int rszARRAY(ARRAY* * p, size_t nrows, size_t ncolumns)
{ size_t i;
unsigned char **temp, *tmp;
if( p==0 || *p==0 )
R 0;
if( (temp= realloc( (*p)->a, nrows * sizeof *temp ) )== NULL )
R 0;
(*p)->a=temp;
for( i=0; i<nrows; i++ )
{
if( i >= (*p)->nrows )
(*p)->a[i]=0; /* non c'è un puntatore risultato di malloc */
if(( tmp=realloc( (*p)->a[i], ncolumns * sizeof *tmp ) )==NULL)
{
if(i)
F( --i; i!=0; --i)
free( (*p)->a[i] );
free( (*p)->a[0] );
free( (*p)->a );/* libera il massimo che può */
(*p)->a = 0;
(*p)->nrows = 0;
(*p)->nco = 0;
R 0;
}
else (*p)->a[i]=tmp;
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns; /* nuove righe e colonne */
return i; /* Ritorna il numero di colonne allocate; */
}
void freeARRAY(ARRAY * p)
{ size_t i;
if( p==0 ) R;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
p->a = 0;
p->nco = 0;
p->nrows = 0;
}
void freeARRAY_d(ARR AY** p)
{ size_t i;
if( p==0 || *p==0 ) R;
for(i=0; i < (*p)->nrows; i++)
free( (*p)->a[i] );
free( (*p)->a );
free(*p);
*p=0;
}
_______
"Chi cerca troverà"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define P printf
#define R return
#define F for
#define NROWS 256
#define NCOLUMNS 256
typedef struct ARRAY{
unsigned char** a;
size_t nrows;
size_t nco;
}ARRAY;
int creaARRAY (ARRAY** p, size_t nrows, size_t ncolumns);
int rszARRAY (ARRAY** p, size_t nrows, size_t ncolumns);
void freeARRAY (ARRAY* p);
void freeARRAY_d(ARR AY** p);
ARRAY* somma (ARRAY* r, ARRAY* a, ARRAY* b);
void stampa (ARRAY* a);
int main(void)
{ size_t i, j, h;
ARRAY my={NULL, 0, 0}, *r=0, *a=0, *b=0, *mmy=&my;
srand((unsigned )time(0));
if(creaARRAY(&m my, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.arra y1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mm y, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.arra y1[255+100][255+100] = \'%c\'\n",
my.a[255+100][255+100]);
}
freeARRAY(&my);
F(h=0; h<1000; ++h)
{if(creaARRAY(& r, 3, 3) * creaARRAY(&a, 3, 3)*
creaARRAY(&b, 3, 3)!= 0 )
{F(i=0; i<3; ++i)
F(j=0; j<3; ++j)
a->a[i][j]= rand()%100;
F(i=0; i<3; ++i)
F(j=0; j<3; ++j)
b->a[i][j]= rand()%100;
if(somma(r, a, b))
{stampa(a);P("+ \n"); stampa(b);P("== \n"); stampa(r);}
}
freeARRAY_d(&r) ; freeARRAY_d(&a) ; freeARRAY_d(&b) ;
}
R 0;
}
void stampa(ARRAY* a)
{ size_t i, j;
if(!a) R ;
F( i=0; i< a->nrows; ++i )
{P("\n");
F( j=0; j< a->nco ; ++j)
P("%3u ", (unsigned) a->a[i][j]);
}
P("\n");
}
ARRAY* somma(ARRAY* r, ARRAY* a, ARRAY* b)
{
size_t i, j;
unsigned char h;
if(r==0||a==0|| b==0|| r->a==0||a->a==0||b->a==0)
R 0;
if(r->nrows!=a->nrows||r->nrows!=b->nrows||a->nrows!=b->nrows)
R 0;
if(r->nco!=a->nco||r->nco!=b->nco||a->nco!=b->nco)
R 0;
F( i=0; i< r->nrows; ++i)
F( j=0; j< r->nco; ++j)
{h=a->a[i][j]+b->a[i][j];
if( h< a->a[i][j] || h< b->a[i][j] )
R 0;
r->a[i][j]=h;
}
R r;
}
int creaARRAY(ARRAY ** p, size_t nrows, size_t ncolumns)
{ size_t i, j=0;
if(p==0) R 0;
if(*p==0) {if( (*p=malloc(size of(**p)))==0 )
R 0;
j=1;
}
if(((*p)->a = malloc(nrows * sizeof( *((*p)->a)))) == NULL)
{if(j) {free( *p ); *p=0;}
else {(*p)->nrows=0; (*p)->nco=0;}
R 0;
}
for( i=0; i<nrows; i++ )
{(*p)->a[i]=malloc( ncolumns * sizeof( *((*p)->a[i]) ) );
if((*p)->a[i] == NULL)
{if(i)
F( --i; i!=0; --i)
free( (*p)->a[i] );
free( (*p)->a[0] );
free( (*p)->a ); /* Libera il massimo che può */
if(j) {free( *p ); *p=0; }
else {(*p)->a=0; (*p)->nrows=0; (*p)->nco=0;}
R 0;
}
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns;
R i; /* Ritorna il numero di colonne allocate; */
}
/* Da usarsi a matrice già creata */
int rszARRAY(ARRAY* * p, size_t nrows, size_t ncolumns)
{ size_t i;
unsigned char **temp, *tmp;
if( p==0 || *p==0 )
R 0;
if( (temp= realloc( (*p)->a, nrows * sizeof *temp ) )== NULL )
R 0;
(*p)->a=temp;
for( i=0; i<nrows; i++ )
{if( i >= (*p)->nrows )
(*p)->a[i]=0; /* non c'è un puntatore risultato di malloc */
if(( tmp=realloc( (*p)->a[i], ncolumns * sizeof *tmp ) )== NULL)
{i= i>=(*p)->nrows ? i: (*p)->nrows;
if(i)
F( --i; i!=0; --i)
free( (*p)->a[i] );
free( (*p)->a[0] );
free( (*p)->a );/* libera il massimo che può */
(*p)->a = 0;
(*p)->nrows = 0;
(*p)->nco = 0;
R 0;
}
else (*p)->a[i]=tmp;
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns; /* nuove righe e colonne */
R i; /* Ritorna il numero di colonne allocate; */
}
void freeARRAY(ARRAY * p)
{ size_t i;
if( p==0 ) R;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
p->a = 0;
p->nco = 0;
p->nrows = 0;
}
void freeARRAY_d(ARR AY** p)
{ size_t i;
if( p==0 || (*p)==0 ) R;
for(i=0; i < (*p)->nrows; i++)
free( (*p)->a[i] );
free( (*p)->a );
free(*p);
*p=0;
}
___________
Chi cerca trova ma questa volta (spero) sarà difficile trovare. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ckroom |
last post by:
Hi, I have a vector of chars: "FFFFFF"
Each 2 chars from the vector in hex represents a decimal number, how can I
convert the vector to 3 decimal values (char *)"FF"->(int)256. I have no
idea.
Thanks!
--
ckroom
http://nazaries.net/~ckroom
|
by: Tom |
last post by:
I'm getting this error when I try to pass a structure to a dll.
An unhandled exception of type 'System.ArgumentException' occured in
Test1.exe
Additional Information: Type could not be marshaled because the length
of an embedded array instance does not match the declared length in the
layout
What does it mean?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |