01-19-2012
They're both wrong. You can't take the address of an expression, only an lvalue -- a variable.
Your compiler shouldn't be letting you do the first one if it is. Its result may be undefined.
10 More Discussions You Might Find Interesting
1. Programming
i have a function:
char *pcCityIdToCountryName(ADMIN_DB_DATA *pstHEader, unit uiCityID)
this returns a pointer to CountryName if cityId is given.
to retrieve countryname i give:
char *CountryName;
CountryName = pcCityIdToCountryName(..................);
but when i compile it is giving :... (5 Replies)
Discussion started by: jazz
5 Replies
2. Programming
void main()
{
int a={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a;
cout<<q-p+1<<endl;
}
The output is 10, how?
if we give cout<<q it will print the address, value won't print....
if we give cout<<p it will print the address, value won't print....
p has the base addr; q... (1 Reply)
Discussion started by: sarwan
1 Replies
3. Programming
can u tell me the reson that why we should not delete a pointer twice.?
if we delete ponter twice then what happen and why this happen
Regards,
Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
4. Programming
could any one tell why the following is showing segmentation fault while using **ptr
but working fine using **a
#include<stdio.h>
... (1 Reply)
Discussion started by: useless79
1 Replies
5. Programming
what is far pointer in C (1 Reply)
Discussion started by: useless79
1 Replies
6. Programming
i am having a string like
" X1 " ---> string lenght is 30
I have stored this to a chararry . ref
so here ref = " X1 "
now i trim the left space by my function . Si the string now becomes
"X1 " ---> string lenght is 15... (3 Replies)
Discussion started by: arunkumar_mca
3 Replies
7. Programming
Hi,
I am trying to divide my input to different type of out puts for some other use.
ex: logical_name : jkl00001
expected out put : model=jkl and num=00001
here is the code i actually written
/*******************************************************************/
void... (11 Replies)
Discussion started by: jagan_kalluri
11 Replies
8. Programming
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies
9. Programming
I am trying to test some operations on a directed list. However, the declaration of a pointer is giving me trouble.
I seem to have done something incorrectly because I get an error:
"listtest.c:29: warning: 'p' may be used uninitialized in this function"
Can anyone help?
This is my code... (6 Replies)
Discussion started by: bluetxxth
6 Replies
10. Programming
I have a problem with scanf() for string pointer as member of a struct.
#include <stdio.h>
#include <stdlib.h>
struct Student {
int studentNumber;
int phoneNumber;
char *studentName; //line 7
// char studentName; //line 8
};
int... (10 Replies)
Discussion started by: yifangt
10 Replies
LEARN ABOUT NETBSD
__alignof__
__ALIGNOF__(3) BSD Library Functions Manual __ALIGNOF__(3)
NAME
__alignof__ -- GNU extension for alignment of an object
SYNOPSIS
int
__alignof__(void x);
DESCRIPTION
The __alignof__() operator returns the alignment of its operand. The operand can be a type or an expression. If the operand is a 'lvalue',
the return value represents the required alignment of the underlying type, not the actual alignment of the specified 'lvalue'.
The returned value is specific to the architecture and the ABI. If the architecture does not impose strict alignment requirements,
__alignof__() returns the minimum required alignment. If __aligned(3) is used to increase the alignment, __alignof__() returns the specified
alignment.
EXAMPLES
The syntax is comparable to the sizeof() operator. If the architecture aligns integers along 32-bit address boundaries, the following should
print the value 4.
(void)printf("%d
", __alignof__(int));
On the other hand, the following example should print the value 1, even though this is unlikely to be the actual alignment of the structure
member.
struct align {
int x;
char y;
} a;
(void)printf("%d
", __alignof__(a.y));
SEE ALSO
gcc(1), attribute(3), offsetof(3), typeof(3)
CAVEATS
This is a non-standard, compiler-specific extension.
BSD
December 20, 2010 BSD