Sponsored Content
Full Discussion: sizeof
Top Forums Programming sizeof Post 86196 by ramneek on Wednesday 12th of October 2005 02:38:07 AM
Old 10-12-2005
but i am getting the result as zero

my program is like this


struct foo
{
char c[];

};


void main()
{
struct foo s;
cout<<sizeof(s);
}



when i compile this and run on solaris 5.8 it gives the output as 0
i dont know why

there is no error in my compilation
 

6 More Discussions You Might Find Interesting

1. Programming

sizeof an array of structure without using 'sizeof' operator

Hi All, is it possible to find out the size of an array of structures ( without using 'sizeof' operator). The condition is we have the array of structure instant but we are not aware of the elements inside the structure. Can someone help me out? Thanks in advance. (18 Replies)
Discussion started by: rvan
18 Replies

2. Programming

How to get the sizeof char pointer

The below code throws the error, since the size of x = 19 is not passed to the cstrCopy function. using namespace std; static void cstrCopy(char *x, const char*y); int main () { char x; const string y = "UNIX FORUM"; cstrCopy(x,y.c_str()); return 0; } void cstrCopy(char *x,... (3 Replies)
Discussion started by: SamRoj
3 Replies

3. Programming

Doubts regarding sizeof() operator

Hi, There are some bewildering sizeof() questions I have in my mind. Could anyone shed some light on this? int main() { printf("%d\n", sizeof(main)); // Ans: 1 } That is, the sizeof() a function identifier though it is treated internally as a pointer gives 1 byte always, why? ... (5 Replies)
Discussion started by: royalibrahim
5 Replies

4. Programming

sizeof(object) in C++

Hi, I have defined the class and call the sizeof(object to class) to get the size. # include <iostream> # include <iomanip> using namespace std; class sample { private: int i; float j; char k; public: sample() { } (2 Replies)
Discussion started by: ramkrix
2 Replies

5. Shell Programming and Scripting

Sizeof a file from directory path in perl

Hai how to find size of a file?? ex : /home/kiran/pdk/sample/calibre this is a path In that I have to find size of a files in side a calibre(it is the folder) like .results or .summary (1 Reply)
Discussion started by: kiran425
1 Replies

6. Programming

Compiler/Runtime uses of sizeof

Ignoring other considerations for a moment and in general ... Would there be a difference in result (dot oh or execution) of: A. strncpy( a, b, sizeof(a) ); vs. B. c = sizeof(a); strncpy( a, b, c ); My general understanding is (at least I think my understanding is) that... (10 Replies)
Discussion started by: GSalisbury
10 Replies
ffi_call(3)						   BSD Library Functions Manual 					       ffi_call(3)

NAME
ffi_call -- Invoke a foreign function. SYNOPSIS
#include <ffi.h> void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue); DESCRIPTION
The ffi_call function provides a simple mechanism for invoking a function without requiring knowledge of the function's interface at compile time. fn is called with the values retrieved from the pointers in the avalue array. The return value from fn is placed in storage pointed to by rvalue. cif contains information describing the data types, sizes and alignments of the arguments to and return value from fn, and must be initialized with ffi_prep_cif before it is used with ffi_call. rvalue must point to storage that is sizeof(ffi_arg) or larger for non-floating point types. For smaller-sized return value types, the ffi_arg or ffi_sarg integral type must be used to hold the return value. EXAMPLES
#include <ffi.h> #include <stdio.h> unsigned char foo(unsigned int, float); int main(int argc, const char **argv) { ffi_cif cif; ffi_type *arg_types[2]; void *arg_values[2]; ffi_status status; // Because the return value from foo() is smaller than sizeof(long), it // must be passed as ffi_arg or ffi_sarg. ffi_arg result; // Specify the data type of each argument. Available types are defined // in <ffi/ffi.h>. arg_types[0] = &ffi_type_uint; arg_types[1] = &ffi_type_float; // Prepare the ffi_cif structure. if ((status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2, &ffi_type_uint8, arg_types)) != FFI_OK) { // Handle the ffi_status error. } // Specify the values of each argument. unsigned int arg1 = 42; float arg2 = 5.1; arg_values[0] = &arg1; arg_values[1] = &arg2; // Invoke the function. ffi_call(&cif, FFI_FN(foo), &result, arg_values); // The ffi_arg 'result' now contains the unsigned char returned from foo(), // which can be accessed by a typecast. printf("result is %hhu", (unsigned char)result); return 0; } // The target function. unsigned char foo(unsigned int x, float y) { unsigned char result = x - y; return result; } SEE ALSO
ffi(3), ffi_prep_cif(3) February 15, 2008
All times are GMT -4. The time now is 04:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy