See subject: how do I calloc (and free the memory, if that's not
free(my_bytes);) this?
TIA! 43 3340
M-One <sp***@uni-one.nl> wrote in message
news:3F***************@uni-one.nl... See subject: how do I calloc (and free the memory, if that's not free(my_bytes);) this?
Have you tried looking up the documentation for calloc
and free?
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned char *my_bytes = calloc(256 * 256, sizeof *my_bytes);
if(my_bytes == NULL)
{
fprintf(stderr, "Cannot allocate memory");
return EXIT_FAILURE;
}
/* whatever */
free(my_bytes);
return EXIT_SUCCESS;
}
-Mike
>> See subject: how do I calloc (and free the memory, if that's not free(my_bytes);) this?
Have you tried looking up the documentation for calloc and free?
Yes; thanks for the example.
Al Bowers <xa*@abowers.combase.com> wrote in message
news:yg****************@news.randori.com... Al Bowers Tampa, Fl USA
Hey Al, how does Lou's hair look? :-)
-Mike (Seattle, WA)
On Sun, 06 Jul 2003 14:26:30 GMT, Al Bowers <xa*@abowers.combase.com>
wrote: M-One wrote: > Question 6.16 discuss this topic. > http://www.eskimo.com/~scs/C-faq/q6.16.html
[...]
#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 **array1;
size_t nrows;
size_t ncolumns;
}ARRAY;
int resizeARRAY(ARRAY *p, size_t nrows, size_t ncolumns);
void freeARRAY(ARRAY *p);
int main(void)
{ ARRAY my={NULL, 0, 0};
if(resizeARRAY(&my, NROWS, NCOLUMNS))
{my.array1[255][255] = 'c';
printf("my.array1[255][555] = \'%c\'\n", my.array1[255][255]);
}
freeARRAY(&my);
return 0;
}
int resizeARRAY(ARRAY* p, size_t nrows, size_t ncolumns)
{ size_t i;
unsigned char **temp;
if( (temp=realloc( p->array1, nrows * sizeof(*temp) )) == NULL )
R 0;
p->array1=temp;
for( i=0; i<nrows; i++ )
{p->array1[i]=malloc( ncolumns * sizeof( *(p->array1[i]) ) );
if(p->array1[i] == NULL)
{F( --i; i!=0; --i)
free( p->array1[i] );
free( p->array1[0] );
free( p->array1 );
R 0;
}
}
p->nrows = nrows ;
p->ncolumns = ncolumns;
return i; /* Ritorna il numero di righe allocate; */
}
void freeARRAY(ARRAY* p)
{ size_t i;
for(i=0; i < p->nrows; i++)
free( p->array1[i] );
free( p->array1 );
p->array1 = 0;
p->ncolumns = 0;
p->nrows = 0;
}
void freeARRAY1(ARRAY* p)
{ size_t i;
for(i=0; i < p->nrows; i++)
free( p->array1[i] );
free( p->array1 );
free(p);
} gi******@giuseppe.wwwew (Giuseppe) wrote (07 Jul 2003) in
news:3f**************@news.tin.it / comp.lang.c: [...] #include <stdio.h> #include <stdlib.h> #define P printf #define R return #define F for
He's back. And as stupid as ever.
--
Martin Ambuhl
Returning soon to the
Fourth Largest City in America
On Mon, 07 Jul 2003 16:17:23 GMT, in comp.lang.c , gi******@giuseppe.wwwew (Giuseppe) wrote: On Sun, 06 Jul 2003 14:26:30 GMT, Al Bowers <xa*@abowers.combase.com> wrote:M-One wrote: > Question 6.16 discuss this topic. > http://www.eskimo.com/~scs/C-faq/q6.16.html [...] #include <stdio.h> #include <stdlib.h> #define P printf #define R return #define F for
Why do you persist in this obfuscatory stupidity? Do you think it
makes you look clever? Do you think its useful for others? Top Tip: it
makes you look a prat and everyone is ignoring you.
typedef struct ARRAY{ unsigned char **array1; size_t nrows; size_t ncolumns; }ARRAY;
By common convention in C, uppercase is reserved for macros,
Microsoft's gratuitous ignoring of that convention notwithstanding.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
In article <3f**************@news.tin.it>, gi******@giuseppe.wwwew
says... #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 **array1; size_t nrows; size_t ncolumns; }ARRAY;
Okay, that's one time too many, I've given up. I don't normally
ever do this, but ...
*plonk*
--
Randy Howard
remove the obvious bits from my address to reply.
Giuseppe <gi******@giuseppe.wwwew> wrote: On Sun, 06 Jul 2003 14:26:30 GMT, Al Bowers <xa*@abowers.combase.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**********@daimlerchrysler.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(ARRAY** p, size_t nrows, size_t ncolumns);
void freeARRAY(ARRAY *p);
void freeARRAY_1(ARRAY *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(ARRAY** p, size_t nrows, size_t ncolumns)
{ size_t i, j=0;
unsigned char **temp;
if(*p==0) {if( (*p=malloc(sizeof(**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(ARRAY* 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******@giuseppe.wwwew (Giuseppe)
wrote: int resizeARRAY(ARRAY** p, size_t nrows, size_t ncolumns) { size_t i, j=0; unsigned char **temp;
if(*p==0) {if( (*p=malloc(sizeof(**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(ARRAY* 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(&mmy, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mmy, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.array1[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.array1[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(sizeof(**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(ARRAY* 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*****@mindspring.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******@giuseppe.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(ARRAY* 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(&mmy, NROWS, NCOLUMNS)) {my.a[255][255] = 'c'; printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]); }
if(rszARRAY(&mmy, NROWS+100, NCOLUMNS+100)) {my.a[255+100][255+100] = 'c'; printf("my.array1[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(ARRAY** 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(&mmy, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mmy, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.array1[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(sizeof(**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(ARRAY** 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(ARRAY** 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(&mmy, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mmy, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.array1[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(sizeof(**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(ARRAY** 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.
On Tue, 08 Jul 2003 16:15:41 GMT, in comp.lang.c , gi******@giuseppe.wwwew (Giuseppe) wrote: #include <stdio.h> #include <stdlib.h> #include <time.h> #define P printf #define R return #define F for
okay, thats enough., You're plonked. Now fsck off.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Richard Heathfield wrote: Giuseppe wrote:
#include <stdio.h> #include <stdlib.h> #include <time.h> #define P printf #define R return #define F for
This code is sufficient evidence that the person writing it is not an experienced C programmer. Any advice he gives should therefore be treated with suspicion.
Those who wish to write such code for kicks have the IOCCC. Those who wish it to be taken seriously are deluding themselves.
I wish he would at least try to take himself seriously,
and recognize that he doesn't even like these macros himself:
printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]);
printf("my.array1[255+100][255+100] = \'%c\'\n"
return i; /* Ritorna il numero di colonne allocate; */
return i; /* Ritorna il numero di colonne allocate; */
for( i=0; i<nrows; i++ )
for( i=0; i<nrows; i++ )
for(i=0; i < p->nrows; i++)
for(i=0; i < (*p)->nrows; i++)
Giuseppe wrote: /* 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; */ }
Same problem as before. You have not considered what whould happen
if you use this function to decrease nrow from a previous allocation.
A hint; lost pointers to previous allocations, ie. memory leak.
--
Al Bowers
Tampa, Fl USA
mailto: xa*@abowers.combase.com (remove the x) http://www.geocities.com/abowers822/
On Tue, 08 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote: Giuseppe wrote: /* 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 */ return i; /* Ritorna il numero di colonne allocate; */ }
Same problem as before. You have not considered what whould happen if you use this function to decrease nrow from a previous allocation. A hint; lost pointers to previous allocations, ie. memory leak.
I have seen it in my last message and
i= i>=(*p)->nrows ? i: (*p)->nrows; is right?
Thank you
Giuseppe wrote: On Tue, 08 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote:
Giuseppe wrote:
/* 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 */ return i; /* Ritorna il numero di colonne allocate; */ }
Same problem as before. You have not considered what whould happen if you use this function to decrease nrow from a previous allocation. A hint; lost pointers to previous allocations, ie. memory leak.
I have seen it in my last message and i= i>=(*p)->nrows ? i: (*p)->nrows; is right?
No.
Take for example that you use the function to allocated an array,
arr[256][256].
Then you come back with this function a reallocate the array,
arr[4][256].
The statement: temp= realloc( (*p)->a, nrows * sizeof *temp )
will reduce the allocation(assuming it is successful), but at
this point you have lost the pointers arr[4],arr[5],.....arr[255]
which pointed to previous allocated memory. So, now, how are you
going to free these allocations?
One way to solve this is redesign the function to allocated
a new array of the new size. Then copy over the data from
the old array that will fit in the new array. Then delete the
old array.
int resizeARRAY(ARRAY *p, size_t nrows, size_t ncolumns)
{
int flag = 1;
size_t i,n;
unsigned char **temp;
/* Create array of new size */
if((temp = malloc(nrows * sizeof *temp)) == NULL) return 0;
for(i = 0; i < nrows; i++)
if((temp[i] = malloc(ncolumns * sizeof **temp)) == NULL)
{
flag = 0;
break;
}
if(flag == 0) /* Allocation error in new array, free and return */
{
for( ; i != 0; i--) free(temp[i-1]);
free(temp);
return 0;
}
/* copy contents of old array to new */
for(i = 0;i < (p->nrows<nrows?p->nrows:nrows) ; i++)
for(n = 0; n < (p->ncolumns<ncolumns?p->ncolumns:ncolumns);n++)
temp[i][n] = p->array1[i][n];
freeARRAY(p);
p->array1 = temp;
p->ncolumns = ncolumns;
p->nrows = nrows;
return 1;
}
void freeARRAY(ARRAY *p)
{
size_t i;
for(i = 0; i < p->nrows; i++)
free(p->array1[i]);
free(p->array1);
p->array1 = NULL;
p->ncolumns = 0;
p->nrows = 0;
return;
}
--
--
Al Bowers
Tampa, Fl USA
mailto: xa*@abowers.combase.com (remove the x) http://www.geocities.com/abowers822/
On Wed, 09 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote: Giuseppe wrote: On Tue, 08 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote:
Giuseppe wrote:
/* 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( nrows < (*p)->nrows )
for( i=nrows; i< (*p)->nrows; ++i )
free( (*p)->a[i] );
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 */ return i; /* Ritorna il numero di colonne allocate; */ }
Same problem as before. You have not considered what whould happen if you use this function to decrease nrow from a previous allocation. A hint; lost pointers to previous allocations, ie. memory leak.
I have seen it in my last message and i= i>=(*p)->nrows ? i: (*p)->nrows; is right?
No. Take for example that you use the function to allocated an array, arr[256][256]. Then you come back with this function a reallocate the array, arr[4][256]. The statement: temp= realloc( (*p)->a, nrows * sizeof *temp ) will reduce the allocation(assuming it is successful), but at this point you have lost the pointers arr[4],arr[5],.....arr[255]
yes, and it could be easy free them in this way
if( nrows < (*p)->nrows )
for( i=nrows; i< (*p)->nrows; ++i )
free( (*p)->a[i] );
but the game could be too much difficult for me.
(but it seems to work ok)
which pointed to previous allocated memory. So, now, how are you going to free these allocations?
One way to solve this is redesign the function to allocated a new array of the new size. Then copy over the data from the old array that will fit in the new array. Then delete the old array.
int resizeARRAY(ARRAY *p, size_t nrows, size_t ncolumns) { int flag = 1; size_t i,n; unsigned char **temp;
/* Create array of new size */ if((temp = malloc(nrows * sizeof *temp)) == NULL) return 0; for(i = 0; i < nrows; i++) if((temp[i] = malloc(ncolumns * sizeof **temp)) == NULL) { flag = 0; break; } if(flag == 0) /* Allocation error in new array, free and return */ { for( ; i != 0; i--) free(temp[i-1]); free(temp); return 0; } /* copy contents of old array to new */ for(i = 0;i < (p->nrows<nrows?p->nrows:nrows) ; i++) for(n = 0; n < (p->ncolumns<ncolumns?p->ncolumns:ncolumns);n++) temp[i][n] = p->array1[i][n];
freeARRAY(p); p->array1 = temp; p->ncolumns = ncolumns; p->nrows = nrows; return 1; }
void freeARRAY(ARRAY *p) { size_t i;
for(i = 0; i < p->nrows; i++) free(p->array1[i]); free(p->array1); p->array1 = NULL; p->ncolumns = 0; p->nrows = 0; return; } -- -- Al Bowers Tampa, Fl USA mailto: xa*@abowers.combase.com (remove the x) http://www.geocities.com/abowers822/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#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(ARRAY** 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(&mmy, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mmy, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
my.a[255+100][255+100]);
}
freeARRAY(&my);
for(h=0; h<50; ++h)
{unsigned len=rand()%20+1;
if(creaARRAY(&r, len, len) * creaARRAY(&a, len, len)*
creaARRAY(&b, len, len)!= 0 )
{for(i=0; i<len; ++i)
for(j=0; j<len; ++j)
a->a[i][j]= rand()%100;
for(i=0; i<len; ++i)
for(j=0; j<len; ++j)
b->a[i][j]= rand()%100;
if(somma(r, a, b))
{stampa(a); printf("+ \n");
stampa(b); printf("==\n");
stampa(r);
}
}
if(rszARRAY(&r, NROWS+100, NCOLUMNS+100))
{(*r).a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
(*r).a[255+100][255+100]);
}
if(rszARRAY(&a, 3, 3))
{(*a).a[2][2] = 'c';
printf("my.array1[2][2] = \'%c\'\n", (*a).a[2][2]);
}
if(rszARRAY(&a, NROWS+100, NCOLUMNS+100))
{(*a).a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
(*a).a[255+100][255+100]);
}
if(rszARRAY(&a, 1, 1))
{(*a).a[0][0] = 'c';
printf("my.array1[0][0] = \'%c\'\n", (*a).a[0][0]);
}
if(rszARRAY(&a, 1, 1))
(*a).a[0][0] = 'c';
//if(rszARRAY(&a, 0, 1));
//if(rszARRAY(&a, 1, 0));
//if(rszARRAY(&a, 0, 0)); non funzionano
if(rszARRAY(&a, 100, 199))
(*a).a[99][99] = 'c';
freeARRAY_d(&r); freeARRAY_d(&a); freeARRAY_d(&b);
}
return 0;
}
void stampa(ARRAY* a)
{size_t i, j;
if(!a) return ;
for( i=0; i< a->nrows; ++i )
{printf("\n");
for( j=0; j< a->nco ; ++j)
printf("%3u ", (unsigned) a->a[i][j]);
}
printf("\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)
return 0;
if(r->nrows!=a->nrows||r->nrows!=b->nrows||a->nrows!=b->nrows)
return 0;
if(r->nco!=a->nco||r->nco!=b->nco||a->nco!=b->nco)
return 0;
for( i=0; i< r->nrows; ++i)
for( 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] )
return 0;
r->a[i][j]=h;
}
return r;
}
int creaARRAY(ARRAY** p, size_t nrows, size_t ncolumns)
{size_t i, j=0;
if(p==0) return 0;
if(*p==0) {if( (*p=malloc(sizeof(**p)))==0 )
return 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;}
return 0;
}
for( i=0; i<nrows; i++ )
{(*p)->a[i]=malloc( ncolumns * sizeof( *((*p)->a[i]) ) );
if((*p)->a[i] == NULL)
{if(i)
{for( --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;}
return 0;
}
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns;
return 1;
}
/* Da usarsi a matrice già creata con creaARRAY (e dimensione>0) */
/* Se riesce a fare il resize ritorna 1 altrimenti **p={0, 0, 0} */
/* *da liberare subito dopo* con l'opportuno freeARRAY */
int rszARRAY(ARRAY** p, size_t nrows, size_t ncolumns)
{size_t i;
unsigned char **temp, *tmp;
if( p==0 || *p==0 )
return 0;
if( nrows < (*p)->nrows )
for( i=nrows; i< (*p)->nrows; ++i )
free( (*p)->a[i] );
if( (temp= realloc( (*p)->a, nrows * sizeof *temp ) )== NULL )
{i = nrows<(*p)->nrows ? nrows: (*p)->nrows ;
goto label;/* It will ok? */
}
(*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;
label:
if(i)
{for(--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;
return 0;
}
else (*p)->a[i]=tmp;
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns; /* nuove righe e colonne */
return 1;
}
/* matrice parzialmente dinamica */
void freeARRAY(ARRAY* p)
{size_t i;
if( p==0 ) return ;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
p->a = 0;
p->nco = 0;
p->nrows = 0;
}
/* matrice totalmente dinamica */
void freeARRAY_d(ARRAY** p)
{size_t i;
if( p==0 || (*p)==0 ) return ;
for(i=0; i < (*p)->nrows; i++)
free((*p)->a[i] );
free( (*p)->a );
free(*p);
*p=0;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#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(ARRAY** 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(&mmy, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mmy, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
my.a[255+100][255+100]);
}
freeARRAY(&my);
for(h=0; h<50; ++h)
{unsigned len=rand()%20+1;
if(creaARRAY(&r, len, len) * creaARRAY(&a, len, len)*
creaARRAY(&b, len, len)!= 0 )
{for(i=0; i<len; ++i)
for(j=0; j<len; ++j)
a->a[i][j]= rand()%100;
for(i=0; i<len; ++i)
for(j=0; j<len; ++j)
b->a[i][j]= rand()%100;
if(somma(r, a, b))
{stampa(a); printf("+ \n");
stampa(b); printf("==\n");
stampa(r);
}
}
if(rszARRAY(&r, NROWS+100, NCOLUMNS+100))
{(*r).a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
(*r).a[255+100][255+100]);
}
if(rszARRAY(&a, 3, 3))
{(*a).a[2][2] = 'c';
printf("my.array1[2][2] = \'%c\'\n", (*a).a[2][2]);
}
if(rszARRAY(&a, NROWS+100, NCOLUMNS+100))
{(*a).a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
(*a).a[255+100][255+100]);
}
if(rszARRAY(&a, 1, 1))
{(*a).a[0][0] = 'c';
printf("my.array1[0][0] = \'%c\'\n", (*a).a[0][0]);
}
if(rszARRAY(&a, 1, 1))
(*a).a[0][0] = 'c';
//if(rszARRAY(&a, 0, 1));
//if(rszARRAY(&a, 1, 0));
//if(rszARRAY(&a, 0, 0)); non funzionano
if(rszARRAY(&a, 100, 199))
(*a).a[99][99] = 'c';
freeARRAY_d(&r); freeARRAY_d(&a); freeARRAY_d(&b);
}
return 0;
}
void stampa(ARRAY* a)
{size_t i, j;
if(!a) return ;
for( i=0; i< a->nrows; ++i )
{printf("\n");
for( j=0; j< a->nco ; ++j)
printf("%3u ", (unsigned) a->a[i][j]);
}
printf("\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)
return 0;
if(r->nrows!=a->nrows||r->nrows!=b->nrows||a->nrows!=b->nrows)
return 0;
if(r->nco!=a->nco||r->nco!=b->nco||a->nco!=b->nco)
return 0;
for( i=0; i< r->nrows; ++i)
for( 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] )
return 0;
r->a[i][j]=h;
}
return r;
}
int creaARRAY(ARRAY** p, size_t nrows, size_t ncolumns)
{size_t i, j=0;
if(p==0) return 0;
if(*p==0) {if( (*p=malloc(sizeof(**p)))==0 )
return 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;}
return 0;
}
for( i=0; i<nrows; i++ )
{(*p)->a[i]=malloc( ncolumns * sizeof( *((*p)->a[i]) ) );
if((*p)->a[i] == NULL)
{if(i)
{for( --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;}
return 0;
}
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns;
return 1;
}
/* rszARRAY()*/
/* Da usarsi a matrice già creata con creaARRAY(). Se riesce a */
/* fare il resize ritorna 1 altrimenti 0 ed **p={0, 0, 0} */
/* *da liberare subito dopo* con l'opportuno freeARRAY */
int rszARRAY(ARRAY** p, size_t nrows, size_t ncolumns)
{size_t i;
unsigned char **temp, *tmp;
if( p==0 || *p==0 )
return 0;
if( nrows < (*p)->nrows )
for( i=nrows; i< (*p)->nrows; ++i )
free( (*p)->a[i] );
if( (temp= realloc( (*p)->a, nrows * sizeof *temp ) )== NULL )
{i = nrows<(*p)->nrows ? nrows: (*p)->nrows ;
goto label;
}
(*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= nrows < (*p)->nrows ? nrows :
(i>=(*p)->nrows ? i: (*p)->nrows);
label:
if(i)
{for(--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;
return 0;
}
else (*p)->a[i]=tmp;
}
(*p)->nrows = nrows ;
(*p)->nco = ncolumns; /* nuove righe e colonne */
return 1;
}
/* matrice parzialmente dinamica */
void freeARRAY(ARRAY* p)
{size_t i;
if( p==0 ) return ;
for(i=0; i < p->nrows; i++)
free( p->a[i] );
free( p->a );
p->a = 0;
p->nco = 0;
p->nrows = 0;
}
/* matrice totalmente dinamica */
void freeARRAY_d(ARRAY** p)
{size_t i;
if( p==0 || (*p)==0 ) return ;
for(i=0; i < (*p)->nrows; i++)
free((*p)->a[i] );
free( (*p)->a );
free(*p);
*p=0;
}
Giuseppe wrote: On Wed, 09 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote:
Giuseppe wrote:
On Tue, 08 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote:
Giuseppe wrote:
>/* 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( nrows < (*p)->nrows ) for( i=nrows; i< (*p)->nrows; ++i ) free( (*p)->a[i] );
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 */ > return i; /* Ritorna il numero di colonne allocate; */ >} >
Same problem as before. You have not considered what whould happen if you use this function to decrease nrow from a previous allocation. A hint; lost pointers to previous allocations, ie. memory leak.
I have seen it in my last message and i= i>=(*p)->nrows ? i: (*p)->nrows; is right? No. Take for example that you use the function to allocated an array, arr[256][256]. Then you come back with this function a reallocate the array, arr[4][256]. The statement: temp= realloc( (*p)->a, nrows * sizeof *temp ) will reduce the allocation(assuming it is successful), but at this point you have lost the pointers arr[4],arr[5],.....arr[255]
yes, and it could be easy free them in this way if( nrows < (*p)->nrows ) for( i=nrows; i< (*p)->nrows; ++i ) free( (*p)->a[i] );
That will solve the memory leak problem. but the game could be too much difficult for me. (but it seems to work ok)
It may work for you but not me. Consider the result should you
have a deallocation/allocation failure. For example,
you resize an old array, arr[256][4], to arr[3][256].
I am less concerned about the deallocation of the rows from 256 to
3 as the allocations of the columns from 4 to 256. There is
the possiblity of allocation failure. It this occurs, the function
aborts allocation of the new array and the old array is deallocated.
So the result is now you have nothing. I would prefer that this
function preserve the integrity of the old array should allocation
of the new array fail.
--
Al Bowers
Tampa, Fl USA
mailto: xa*@abowers.combase.com (remove the x) http://www.geocities.com/abowers822/
On Thu, 10 Jul 2003 -0400, Al Bowers <xa*@abowers.combase.com> wrote: Giuseppe wrote: On Wed, 09 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote:Giuseppe wrote: On Tue, 08 Jul 2003-0400, Al Bowers <xa*@abowers.combase.com> wrote: >Giuseppe wrote: >>/* 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( nrows < (*p)->nrows ) for( i=nrows; i< (*p)->nrows; ++i ) free( (*p)->a[i] );
>> 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 */ >> return i; /* Ritorna il numero di colonne allocate; */ >>} >> > >Same problem as before. You have not considered what whould happen >if you use this function to decrease nrow from a previous allocation. >A hint; lost pointers to previous allocations, ie. memory leak.
I have seen it in my last message and i= i>=(*p)->nrows ? i: (*p)->nrows; is right?
No. Take for example that you use the function to allocated an array, arr[256][256]. Then you come back with this function a reallocate the array, arr[4][256]. The statement: temp= realloc( (*p)->a, nrows * sizeof *temp ) will reduce the allocation(assuming it is successful), but at this point you have lost the pointers arr[4],arr[5],.....arr[255]
yes, and it could be easy free them in this way if( nrows < (*p)->nrows ) for( i=nrows; i< (*p)->nrows; ++i ) free( (*p)->a[i] );
That will solve the memory leak problem.
but the game could be too much difficult for me. (but it seems to work ok)
It may work for you but not me. Consider the result should you have a deallocation/allocation failure. For example, you resize an old array, arr[256][4], to arr[3][256]. I am less concerned about the deallocation of the rows from 256 to 3 as the allocations of the columns from 4 to 256. There is the possiblity of allocation failure. It this occurs, the function aborts allocation of the new array and the old array is deallocated. So the result is now you have nothing. I would prefer that this function preserve the integrity of the old array should allocation of the new array fail.
So this could be better?
__
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define NROWS 256
#define NCOLUMNS 256
int mai=0;
typedef struct ARRAY{
unsigned char** a;
size_t nrows;
size_t nco;
}ARRAY;
int rszARRAY (ARRAY** p, size_t nrows, size_t ncolumns);
void freeARRAY (ARRAY* p);
void freeARRAY_d(ARRAY** p);
ARRAY* somma (ARRAY* r, ARRAY* a, ARRAY* b);
void stampa (ARRAY* a);
int main(void)
{size_t i, j, h, len;
ARRAY my={NULL, 0, 0}, *r=0, *a=0, *b=0, *mmy=&my;
srand((unsigned)time(0));
if(rszARRAY(&mmy, NROWS, NCOLUMNS))
{my.a[255][255] = 'c';
printf("my.array1[255][255] = \'%c\'\n", my.a[255][255]);
}
if(rszARRAY(&mmy, NROWS+100, NCOLUMNS+100))
{my.a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
my.a[255+100][255+100]);
}
freeARRAY(&my);
for(h=0; h<10; ++h)
{len=rand()%20+1;
if(rszARRAY(&r, len, len) * rszARRAY(&a, len, len) *
rszARRAY(&b, len, len)== 0 )
goto lab;
for(i=0; i<len; ++i)
for(j=0; j<len; ++j)
a->a[i][j]= rand()%100;
for(i=0; i<len; ++i)
for(j=0; j<len; ++j)
b->a[i][j]= rand()%100;
if(somma(r, a, b))
{stampa(a); printf("+ \n");
stampa(b); printf("==\n");
stampa(r);
}
if(rszARRAY(&r, NROWS+100, NCOLUMNS+100))
{(*r).a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
(*r).a[255+100][255+100]);
}
if(rszARRAY(&a, 3, 3))
{(*a).a[2][2] = 'c';
printf("my.array1[2][2] = \'%c\'\n", (*a).a[2][2]);
}
if(rszARRAY(&a, NROWS+100, NCOLUMNS+100))
{(*a).a[255+100][255+100] = 'c';
printf("my.array1[255+100][255+100] = \'%c\'\n",
(*a).a[255+100][255+100]);
}
if(rszARRAY(&a, 1, 1))
{(*a).a[0][0] = 'c';
printf("my.array1[0][0] = \'%c\'\n", (*a).a[0][0]);
}
if(rszARRAY(&a, 1, 1))
(*a).a[0][0] = 'c';
printf("\n");
mai=1;
if(rszARRAY(&a, 1, 2000000000))
(*a).a[0][0] = 'c';
else printf(" c allocazione fallita\n");
printf("DOPO\n");
mai=1;
if(rszARRAY(&a, -1, 1))
(*a).a[0][0] = 'c';
else printf("r allocazione fallita\n");
if(rszARRAY(&a, -1, 1))
(*a).a[0][0] = 'c';
else printf("r allocazione fallita\n");
mai=1;
if(rszARRAY(&a, 1, 2000000000))
(*a).a[0][0] = 'c';
else printf(" c allocazione fallita\n");
printf("DOPO\n");
if(rszARRAY(&a, 1, 2000000000))
(*a).a[0][0] = 'c';
else printf(" c allocazione fallita\n");
printf("DOPO\n");
if(rszARRAY(&a, 100, 199))
(*a).a[99][99] = 'c';
else printf("allocazione fallita\n");
if(rszARRAY(&a, 1, 2000000000))
(*a).a[0][0] = 'c';
else printf(" c allocazione fallita\n");
lab:
freeARRAY_d(&r); freeARRAY_d(&a); freeARRAY_d(&b);
}
return 0;
}
void stampa(ARRAY* a)
{size_t i, j;
if(!a) return ;
for( i=0; i< a->nrows; ++i )
{printf("\n");
for( j=0; j< a->nco ; ++j)
printf("%3u ", (unsigned) a->a[i][j]);
}
printf("\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)
return 0;
if(r->nrows!=a->nrows||r->nrows!=b->nrows||a->nrows!=b->nrows)
return 0;
if(r->nco!=a->nco||r->nco!=b->nco||a->nco!=b->nco)
return 0;
for( i=0; i< r->nrows; ++i)
for( 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] )
return 0;
r->a[i][j]=h;
}
return r;
}
void freeARRAY(ARRAY* p)
{size_t i;
if( p==0 ) return ;
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(ARRAY** p)
{size_t i;
if( p==0 || (*p)==0 ) return ;
for(i=0; i < (*p)->nrows; i++)
free((*p)->a[i] );
free( (*p)->a );
free(*p);
*p=0;
}
/* rszARRAY()*/
/* Serve per inizializzare la matrice e per fare resize. */
/* Se riesce a fare il resize ritorna 1 altrimenti ritorna */
/* 0 ed **p non viene toccato (rimane allocato se allocato).*/
/* Deve essere nrows>0 e nco>0, mentre **p=&y ove ARRAY *y=0*/
/* (allocazione totalmente dinamica);oppure ARRAY my={0,0,0}*/
/* e ARRAY *y=&my (allocazione parzialmente dinamica) */
/* oppure y già allocato con rszARRAY() prima. */
int rszARRAY(ARRAY** p, size_t nrows, size_t nco)
{size_t i, j, u, v;
unsigned char **a;
if( p==0 ) return 0;
if( ( a=malloc( nrows * sizeof *a) )== NULL )
return 0;
for(i=0; i<nrows; ++i)
{a[i]= malloc(nco * sizeof **a);
if(a[i]==0)
{
label:
if(i)
{for(--i; i!=0; --i)
free( a[i] );
free(a[0]);
}
free(a);
return 0;
}
}
if(*p==0)
{if(( *p=malloc(sizeof **p) )==0 )
goto label;
(*p)->a = a ;
(*p)->nrows = nrows;
(*p)->nco = nco ;
return 1;
}
/* Why we have to copy? */
u= nrows <= (*p)->nrows ? nrows : (*p)->nrows;
v= nco <= (*p)->nco ? nco : (*p)->nco ;
for(i=0; i<u; ++i )
for(j=0; j<v; ++j)
a[i][j]= (*p)->a[i][j];
for(i=u; i<nrows; ++i )
for(j=v; j<nco; ++j )
a[i][j]= 0;
/* end question */
freeARRAY(*p);
(*p)->a = a ;
(*p)->nrows = nrows;
(*p)->nco = nco ; /* nuove righe e colonne */
return 1;
}
Mark McIntyre wrote: Top Tip: it makes you look a prat and everyone is ignoring you.
Self-evidentially not the case. ;-)
--
|_ CJSonnack <Ch***@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
On Fri, 11 Jul 2003 12:17:42 -0500, in comp.lang.c , Programmer Dude
<cj*******@mmm.com> wrote: Mark McIntyre wrote:
Top Tip: it makes you look a prat and everyone is ignoring you.
Self-evidentially not the case. ;-)
s/every/nearly every/
ps there's no such word as evidentially,... :-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Mark McIntyre wrote: ps there's no such word as evidentially,... :-)
One entry found for evidential.
Main Entry: ev·i·den·tial
Pronunciation: "e-v&-'den(t)-sh&l
Function: adjective
Date: 1641
: EVIDENTIARY 1
- ev·i·den·tial·ly adverb
Brian Rodenborn
On Fri, 11 Jul 2003 23:26:41 GMT, in comp.lang.c , Default User
<fi********@company.com> wrote:
Mark McIntyre wrote:
ps there's no such word as evidentially,... :-)
One entry found for evidential.
In an american dictionary. And it doesn't mean what you're using it to
mean anyway.... Sheesh, americans...:-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Mark McIntyre wrote: On Fri, 11 Jul 2003 23:26:41 GMT, in comp.lang.c , Default User <fi********@company.com> wrote:
Mark McIntyre wrote:
ps there's no such word as evidentially,... :-)
One entry found for evidential.
In an american dictionary. And it doesn't mean what you're using it to mean anyway.... Sheesh, americans...:-)
Yeah right. Rule number one for usenet, never correct someone's grammar
or spelling because it isn't polite. Rule number two, really don't do it
if you don't know what you are talking about.
Brian Rodenborn
Mark McIntyre wrote: On Fri, 11 Jul 2003 23:26:41 GMT, in comp.lang.c , Default User <fi********@company.com> wrote: Mark McIntyre wrote:
ps there's no such word as evidentially,... :-)
One entry found for evidential.
In an american dictionary. And it doesn't mean what you're using it to mean anyway.... Sheesh, americans...:-)
That type of face saving attempt,
is known as the "No True Scotsman" fallacy. http://www.google.com/search?hl=en&l...ue+scotsman%22
--
pete
On Mon, 14 Jul 2003 17:37:33 -0400, in comp.lang.c , pete
<pf*****@mindspring.com> wrote: Mark McIntyre wrote: On Fri, 11 Jul 2003 23:26:41 GMT, in comp.lang.c , Default User <fi********@company.com> wrote: >Mark McIntyre wrote: > >> ps there's no such word as evidentially,... :-) >One entry found for evidential.
In an american dictionary. And it doesn't mean what you're using it to mean anyway.... Sheesh, americans...:-)
That type of face saving attempt,
Who's saving face? It doesn't mean what he meant it to mean, if you
see what I mean :-)
is known as the "No True Scotsman" fallacy.
are you spillin' my pint, or chewin' a brick, laddie? Oootside, noo,
youse. And yer mammy better hae her sowin kit handy fer when ye gets
hame...
:-)
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
(Sheeze,... only in clc.... )
Mark McIntyre wrote: >>> Top Tip: it makes you look a prat and everyone is ignoring >>> you. >> >> Self-evidentially not the case. ;-) > > ps there's no such word as evidentially,... :-)
Incorrect.
It doesn't mean what he meant it to mean, if you see what I mean
Incorrect. It means exactly what I meant it to mean.
--
|_ CJSonnack <Ch***@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
On Tue, 15 Jul 2003 12:15:26 -0500, Programmer Dude
<cj*******@mmm.com> wrote: (Sheeze,... only in clc.... )
Mark McIntyre wrote:
>>>> Top Tip: it makes you look a prat and everyone is ignoring >>>> you. >>> >>> Self-evidentially not the case. ;-) >> >> ps there's no such word as evidentially,... :-)
Incorrect.
It doesn't mean what he meant it to mean, if you see what I mean
Incorrect. It means exactly what I meant it to mean.
Since your usage of the word doesn't seem to correspond with the
dictionary meaning, maybe you could share what you mean it to mean.
Originally, I thought you had mis-typed "evidently", but apparently
you had something else in mind.
--
Al Balmer
Balmer Consulting re************************@att.net
On Tue, 15 Jul 2003, Programmer Dude wrote: Mark McIntyre wrote:>>>> Top Tip: it makes you look a prat and everyone is ignoring >>>> you. >>> >>> Self-evidentially not the case. ;-) >> >> ps there's no such word as evidentially,... :-)
Incorrect.
It doesn't mean what he meant it to mean, if you see what I mean
Incorrect. It means exactly what I meant it to mean.
"When I use a word," Humpty Dumpty said, in rather a scornful tone,
"it means just what I choose it to mean - neither more nor less."
"The question is," said Alice, "whether you can make words mean so many
different things."
"The question is," said Humpty Dumpty, "which is to be master - that's
all."
Alan Balmer wrote:
}} Self-evidentially not the case. ;-) It means exactly what I meant it to mean.
Since your usage of the word doesn't seem to correspond with the dictionary meaning, maybe you could share what you mean it to mean.
The evidence is clear to ones self.
"Self-evident" is very similar, but "evident" has a slightly
different shade of meaning (syn. "manifest" for e.g.). Webster
defines it as "evident without *proof* or reasoning".
I intentionally was referring to the plainly-visible evidence.
Proof and reasoning were extant.
--
|_ CJSonnack <Ch***@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
On Tue, 15 Jul 2003 23:34:00 +0100, Mark McIntyre
<ma**********@spamcop.net> wrote: On Tue, 15 Jul 2003 11:19:47 -0700, in comp.lang.c , Alan Balmer <al******@att.net> wrote:
On Tue, 15 Jul 2003 12:15:26 -0500, Programmer Dude <cj*******@mmm.com> wrote:
Incorrect. It means exactly what I meant it to mean. Since your usage of the word doesn't seem to correspond with the dictionary meaning, maybe you could share what you mean it to mean.
Originally, I thought you had mis-typed "evidently", but apparently you had something else in mind.
IMO he meant it to mean "evidently" but deliberately misspelled it as a joke. Which has of course got out of hand as we've all got increasingly anal.... :-()
Personally, I'm so impressed by the latest obfuscation that I will
retire in awe, and say no more.
--
Al Balmer
Balmer Consulting re************************@att.net
Mark McIntyre wrote: IMO he meant it to mean "evidently"...
Nope.
...but deliberately misspelled it as a joke.
Nope.
(The joke, if any, is your *opinions* about what *I* meant.)
Which has of course got out of hand as we've all got increasingly anal.... :-()
Such is clc. ;-|
Alan Balmer wrote:
Personally, I'm so impressed by the latest obfuscation...
Call it what you will if that makes you feel better.
--
|_ CJSonnack <Ch***@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
On Wed, 16 Jul 2003 15:14:24 -0500, in comp.lang.c , Programmer Dude
<cj*******@mmm.com> wrote:
(stuff)
yeah, whatever. Most of us are trying to turn this thread back into
light humour, Chris. You can take it seriously if you want.
ICBWBYLAPIYD.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =--- 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.
...
|
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...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |