comp.lang.c
  Home FAQ Contact Sign in
comp.lang.c only
 
Advanced search
December 2007
motuwethfrsasuw
     12 48
3456789 49
10111213141516 50
17181920212223 51
24252627282930 52
31       1
2007
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.c Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Question about pointers and multi-dimension arrays         


Author: DiAvOl
Date: Dec 26, 2007 23:51

Hello everyone, merry christmas!

I have some questions about the following program:

arrtest.c
------------

#include

int main(int agc, char *argv[]) {
int array2d[2][2] = { {1,2} , {3,4} };
int (* arrp)[2] = array2d;

printf("&array2d = %%p\tarray2d = %%p\t*array2d = %%p\n", &array2d,
array2d, *array2d);
printf("&arrp = %%p\tarp = %%p\t*arrp = %%p\t**arp = %%d\n", &arrp,
arrp, *arrp, **arrp);

return 0;
}

When I compile and run the program I get the following results:

&array2d = 0xbfd9e880 array2d = 0xbfd9e880 *array2d = 0xbfd9e880
&arrp = 0xbfd9e890 arrp = 0xbfd9e880 *arrp =
0xbfd9e880 **arrp = 1

My questions are:
Show full article (1.27Kb)
17 Comments
  setjump and longjump         


Author: pal
Date: Dec 26, 2007 22:51

hi all,

Can anybody explain about setjump and longjump functions if u have
time to spend on this.

Thanks,
pal
6 Comments
  A form of arithmetic based on source code         


Author: Logan Lee
Date: Dec 26, 2007 21:12

4 Comments
  How memory function free() knows how much memory to free.         


Author: Panduranga Chary
Date: Dec 26, 2007 20:30

Hi,

How does the memory management function 'free()' frees the memory
pointed by a pointer variable at run time. how does it know the size.
if there is way when free() can do, then why can't we do it
externally?.

Thanks
Panduranga Chary
2 Comments
  Callback Function Stack Overflow         


Author: jack113256
Date: Dec 26, 2007 19:14

Hi everyone:
I have a question in using Callback function, there is my code:

/******* code start *********/
#include

void a();
void b();
void run();
int state;

int main()
{
state = 0;
run();
}
Show full article (1.05Kb)
3 Comments
  Porting Windows program to BSD         


Author: drhowarddrfine
Date: Dec 26, 2007 18:15

I have an open source Windows program I would like to port to
FreeBSD. I tried compiling it 'as is' and, so far, it only trips up
on MS/Windows definitions, such as 'ulong'. Is there a cross-check
list to find equivalent typedefs, defines, etc. between gcc and
Windows stuff? Is there a software 'converter' of sorts, too?
5 Comments
  Problem passing a string to a function         


Author: Shashank
Date: Dec 26, 2007 16:58

Hi,
I am passing a tcpdump filter to a function which compiles the filter
using pcap_compile and then sets it.
Here is the filter,

ip[12:4]>=0x0000 and ip[12:4] <=0xd9295a3 and ip[16:4] >=0x0000 and
ip[16:4] <=0x3ca9b416 and tcp[0:2]>=0 and tcp[0:2]<=23923 and
tcp[2:2]>=0 and tcp[2:2]<=64582 and tcp[2:2]<=655355

I have many threads passing different filters of a similar form to
the same function.

The problem is, 8 out of 10 times, the string gets passed successfully
and compiled without any problem, but the 2 times, the string gets
manipulated in a random manner.

For example, in this case, the filter was passed as

ip[12:4]>=0x0000 and ip[12:4] <=0xd9295a3 and ip[16:4] >=0x0000 and
ip[16:4] <=0x3ca9b416 and tcp[0:2]>=0 and tcp[0:2]<=23923 and
tcp[2:2]>=0 and tcp[2:2]<=64582 tcp[2:2]<=655355

which of course resulted in pcap_compile raising a syntax error.

Here is a part of the output for 10 threads:

ip[12:4]>=0x0000 and ip[12:4] <=0x4e82b543 and ip[16:4] >=0x0000 and
ip[16:4] <=0x6f835b87 and tcp[0:2]>=0 and tcp[0:2]<=13052 and
tcp[2:2]>=0 and tcp[2:2]<=14069n
Couldn't parse filter ip[12:4]>=0x0000...
Show full article (3.49Kb)
3 Comments
  Advice on using FFTW         


Author: Stephen.Schoenberger
Date: Dec 26, 2007 14:15

Hello,

I am looking for some advice/guidance on using the FFTW (fftw.org)
package to do 2D FFT on some bitmap images. I have bitmaps broken up
into small fragments and need to perform the 2D FFT on each of those.
The documentation on performing this task is a bit sparse so I figured
my best luck would be to turn to the newsgroups.

Thanks
25 Comments
  Programming in standard c         


Author: jacob navia
Date: Dec 26, 2007 12:54

In my "Happy Christmas" message, I proposed a function to read
a file into a RAM buffer and return that buffer or NULL if
the file doesn't exist or some other error is found.

It is interesting to see that the answers to that message prove that
programming exclusively in standard C is completely impossible even
for a small and ridiculously simple program like the one I proposed.

1 I read the file contents in binary mode, what should allow me
to use ftell/fseek to determine the file size.

No objections to this were raised, except of course the obvious
one, if the "file" was some file associated with stdin, for
instance under some unix machine /dev/tty01 or similar...

I did not test for this since it is impossible in standard C:
isatty() is not in the standard.

2) There is NO portable way to determine which characters should be
ignored when transforming a binary file into a text file. One
reader (CB Falconer) proposed to open the file in binary mode
and then in text mode and compare the two buffers to see which
characters were missing... Well, that would be too expensive.
Show full article (1.87Kb)
288 Comments
  question about void typecast         


Author: brad2000
Date: Dec 26, 2007 08:25

I was doing a little bit of reading in the ISO C spec. about
typecasting to a void type. This caused me to have a question. In
particular, I'm curious to know about section 6.3.2.2 where the specs
says "is evaluated as a void expression, its value or designator is
discarded."

If I do the following:

#include

int
main(int argc, char **argv)
{
int s = 12;

printf("non-void type = 0x%%x\n", s);

(void)s;

return(0);
}

What is the effect of typecasting s to a void type. Does the compiler
just treat the line as a null statement?

Thanks.

-brad walker
8 Comments
1 2