|
|
Up |
|
|
  |
Author: juerg.lemkejuerg.lemke
Date: Dec 3, 2007 14:45
Hi everyone
I am interested in having multiple functions with different prototypes
and deciding, by setting a pointer, which of them to use later in the
program.
Eg:
int f1(void);
char* f2(int);
/* ... many more of these to choose from */
/* ? correct declaration of generic_ptr ? */
if (/*...*/)
generic_ptr = f1;
else
generic_ptr = f2;
generic_ptr(/* using correct args */)
How should I define generic_ptr? Is (void*) ok? It seems to work on my
machine, but I would like to know if this is standard/portable.
Thank you for any help
Juergen
|
| |
|
| |
9 Comments |
|
  |
Author: Chris TorekChris Torek
Date: Dec 3, 2007 12:20
In article i12g2000prf.googlegroups.com>
zhangsonglovexiaoniuniu@gmail.com gmail.com> wrote:
>... i know [the machine uses a particular] byte order ...
>my question is what's the bit order?
"Ordering", also known as "endianness", arises from the process of
taking something apart at one location, then putting it back together
again at a new, different place.
Suppose you are moving from one apartment to another, and you need
to have your bed moved. The obvious, simple way to do this is to
take the bed out of the first apartment, load it on a truck, cart
it to the new place, and unload it. But what if the bed is too
big for the truck? Or, what if (for some reason) it is a whole lot
cheaper to saw the bed into pieces that fit in small boxes, and
ship those?
In this case, you get Fred to take the bed apart into little pieces.
The bed is then shipped to the new place, where Joe puts it back
together.
|
| Show full article (2.66Kb) |
|
| |
no comments
|
|
  |
Author: jacob naviajacob navia
Date: Dec 3, 2007 11:45
Since standard C doesn't provide any way for the programmer to direct
the compiler as to how to layout structures, most compilers provide some
way to do this, albeit in different forms.
Microsoft (and lcc-win) uses
#pragma pack(1)
Gcc uses
__attribute__ {(packed)}
Has anyone seen other directives in other compilers?
Specifically, Microsoft allows to pack structures with some integer
constant (pack(2) for instance), but gcc doesn't seem to allow this.
What other semantic differences could exist there?
I am writing this part of my tutorial, and I would like to make a table
about the constructs used by the various compilers. Note that under
windows you must know this kind of stuff since windows uses packed
structures extensively.
|
| Show full article (0.87Kb) |
|
68 Comments |
|
  |
Author: Spiros BousbourasSpiros Bousbouras
Date: Dec 3, 2007 09:52
I'm thinking of adding a command to vim for removing
white space from the end of each line of a C source
file. Can anyone think of a situation where such white
space might be useful ?
|
| |
|
11 Comments |
|
  |
Author: ramuramu
Date: Dec 3, 2007 09:13
Hi,
Could anyone please tell me how to dereference a pointer to an
array of pointers?
Regards
|
| |
|
5 Comments |
|
  |
Author: RoSRoS
Date: Dec 3, 2007 08:21
what does it say the standard for below program?
it has to run or not? or it is UB?
it is better know there is a error or the portability?
it compile and run with gcc?
-------------------------------
#include
int main(void)
{char *p="123";
printf("jijdid\n", p);
return 0;
}
-------------------------------
|
| |
|
9 Comments |
|
  |
Author: James FangJames Fang
Date: Dec 3, 2007 08:13
On Dec 3, 12:45 pm, "zhangsonglovexiaoniu...@ gmail.com"
gmail.com> wrote:
> hi all,
>
> i get a problem:
>
> assume we have a variable with 2 byte -- *b = 0x0102*,
>
> and i know in memory its byte order as follows:
>
> (little endian)
> low ----->high
> 0x02 0x01
> (big endian)
> low ---->high
> 0x01 0x02
>
> now my question is what's the bit order?it is like:
>
> low ----->high ...
|
| Show full article (0.60Kb) |
|
no comments
|
|
  |
Author: sophia.agnessophia.agnes
Date: Dec 3, 2007 07:56
Dear all,
what are the major expression types in c?
i have seen the following types of expressions
1) constant expressions
2) integral expressions
3) float expressions
4) pointer expressions
is there any other expression type in c?
|
| |
|
2 Comments |
|
  |
Author: aarklonaarklon
Date: Dec 3, 2007 07:16
Hi all,
consider this,
int x=19;
now &x = 1789; /*this is illegal in c*/
now my question is is there a round about way to do this in
C....??????
|
| |
|
8 Comments |
|
  |
|
|
  |
Author: nbeyjrnbeyjr
Date: Dec 3, 2007 07:07
The following electronics can be viewed here: Sharp 46 television,
Asus 13.3 inch notebook, Cobra Digital DC6415 6.0 Mega Pixels 3 in 1
Mode Digital Camera/PC Camera/Camcorder, FUJI Fujifilm FinePix 2650
2MP Digital Camera w/ 3x Optical Zoom.
With the following numbers to look them up:
110201346720
110201348739
110201355364
110201358325
www.ebay.com
nnb_jr@ yahoo.com
|
| |
|
no comments
|
|
|
|
|
|
|