void « integer « C Data Type Q&A

Home
C Data Type Q&A
1.binary
2.bit
3.byte
4.char
5.character
6.decimal
7.Development
8.float
9.hex
10.integer
11.prime
12.random
13.struct
C Data Type Q&A » integer » void 

1. How do I convert from void * back to int    stackoverflow.com

if I have

int a= 5;
long b= 10;
int count0 = 2;
void ** args0;
args0 = (void **)malloc(count0 * sizeof(void *));
args0[0] = (void *)&a;
args0[1] = (void *)&b;
how can I convert from args[0] and args0[1] ...

3. c89: Convert an int to void* and back    stackoverflow.com

First off, this is not a dupe of: Is it safe to cast an int to void pointer and back to int again? The difference in the questions is this: I'm only ...

4. Is it always safe to convert an integer value to void* and back again in POSIX?    stackoverflow.com

This question is almost a duplicate of some others I've found, but this specifically concerns POSIX, and a very common example in pthreads that I've encountered several times. I'm mostly concerned ...

5. int main(void) { func(); func(6); return 0; } int func(    bytes.com

This situation occurs due to not using function prototypes. If you do, you will get an error and the build will fail. As it is, func() produces a warning that it is not defined and is assumed an extern returning an int. The linker sees func() as an unresolved function and it has func(int) available. In C, func() just means a ...

6. How do you track type information when converting int* to void*    bytes.com

On 18 Sep, 12:27, Chad How would you track the type infornation? why are you casting ...

7. int main(void) is better than int main()    bytes.com

On 2008-01-03 13:10, Lars Uffmann wrote: Now we're getting to where it becomes interesting :) > James Kanze wrote: >>>int main(void) is better than int main() >>There is no difference. >As far as the compiler is concerned, no. As far as anyone who >reads the code is concerned, the first marks you as a C hacker, >who doesn't understand C++. > ...

9. what's the difference between int main() and void main()?    bytes.com

hlo, i've got a question , some people here gived me advice to use int main(),actually , i dont know what int main() is,but in my manual that i read ,the writer of the book says that i've got to use void main(). dont know what the problem is , help me! The difference is simple: 'void main()' is just plain ...

10. int main(void) { return main(); }    bytes.com

Is that in the object line a conforming program? If so, why? If not, why? I'd expect it to be much like int main(void) { for (;;); } But if I compile it with lcc-win32 and run it in its rundos.exe, it says the program exits with a return value of -1073741819 (i.e. -2^30 + 5) after 0.032 seconds or so. ...

11. error C2040: 'hFlag' : 'void *' differs in levels of indirection from 'int'    bytes.com

I am using a global which is a void* I have it defined in one file as: void* hFlag; and one other header file as: extern void* hFlag; But I get this compile error: error C2040: 'hFlag' : 'void *' differs in levels of indirection from 'int' I can't understand what the problem is. I have another global variable which is ...

12. int main and void main    bytes.com

In C++, you can NEVER use a void main(). It must always be int main(). in C++, returning a 1 inside main indicates that there was an error. A common occurrence of this is when you are trying to input from a file, but the file cannot be loaded. It correctly exits the program, but with the added note that there ...

13. invalid conversion from void* to int**    bytes.com

Martin Jrgensen Hi, I'm using this alloc_mem-function: - - - - - - - - - - - - - - - - - - - - - - - - void *alloc_mem (size_t num_elems, size_t elem_size, char *filename, int line, size_t *total_mem) { void *mem; size_t size = num_elems*elem_size; size += (sizeof (size_t) <= elem_size) ? elem_size : sizeof (size_t); ...

14. Portable integer type which can hold int, wchar_t, and void *    bytes.com

I'm trying to portably define a type which is wide enough to hold an int, a wchar_t, or a void *. Here's what I've got: #include #include #include #if INT_MAX > INT32_MAX || WCHAR_MAX > INT32_MAX || \ INTPTR_MAX > INT32_MAX typedef int64_t funky_type; #elif INT_MAX > INT16_MAX || WCHAR_MAX > INT16_MAX || \ INTPTR_MAX > INT16_MAX typedef ...

15. int main(void) Why void?    bytes.com

rahulsinner@gmail.com schrieb:[color=blue] > I have noticed everyone using "int main(void)".But doesnt the > standard pronounces it as > "int main(int argc,char *argv[])".And if i don't specify arguments,why > can't i simply put it as "int main()"[/color] See FAQ 11.12a. As it is usually better to make every function declaration a prototype, it is only consistent and sensible to do the same ...

16. CAN WE TYPE CAST AN INTEGER AS (VOID *)X..(Like can I return a value (void *)x)    bytes.com

now suppose I have declared an integer value inside a function as int x; now if the return type of the function is of type (void *) then can I write return((void *)x) in side the function? I came across this in a document on multithreading in C..I can post the exact portion of code which works correctly with such an ...

17. int main() or int main(void)?    bytes.com

Thanks! I does not mean the prototype, but full function: I think the main function is only used only once in a .c file, so it does not need a pre-declare or something like that. Am I right? Thanks for your help! Should I use: #include int main() { .... return 0; } or this: #include int main(void) { ...

18. subroutine question int or void for declared return value    cboard.cprogramming.com

main() is special. A program is not even required to work correctly (or compile or link) if main() does not return int. Or, more formally, an implementation (compiler, library, etc) is only required to support int main(). Other functions can have any return type the programmer might consider appropriate (int, void, pointers, double, struct types, enums, etc).

19. int main vs void main    cboard.cprogramming.com

Note, in unhosted environments like embedded systems (one's without a "typical" OS), the standard does not require int main, since there is no environment to return a value to. Thus, an embedded compiler may allow or even require void main, though personally I have not seen such an implementation. We occasionally see void main used on embedded projects here, though it's ...

20. why sometimes void (main) and sometimes int main ()    cboard.cprogramming.com

The first thing to understand is that void main() is NEVER right. It's more complex than this, as you will discover when learning more, but the core if it is that main() is called by the operating system as a function, just like you would call a function from inside your program... programs are really just functions that are run by ...

21. int getInteger(void);    cboard.cprogramming.com

22. Cast void* to int* problem. I think my understanding of casting is flawed.    cboard.cprogramming.com

Yeah, that looks a lot cleaner. Thanks for the pointer (hehe, I made a pun). I was getting a seg fault because it would fail to allocate nodes if the didn't exist, but I fixed it. Here's the completely working version: Code: void *write_vector(struct vector *v, int index, void *data) { struct data_node *cur_node; cur_node = v->data; /* Set the current ...

23. void * -> int    cboard.cprogramming.com

Code: #include typedef struct { int index; int max; void **a; } list; list arraylist() { list alist; alist.a = malloc(10); alist.max = 10; alist.index = 0; return alist; } void add(list *l, void *obj) { if (l->index > l->max) realloc(&(l->a), l->max*2); l->max *= 2; l->a[l->index++] = obj; } void delete(list *l, int index) { l->a[index] = NULL; } void ...

24. Question about int and void main()    cboard.cprogramming.com

25. A question about void(main) and int(main)    cboard.cprogramming.com

26. differences between int main and void    cboard.cprogramming.com

From http://www.faqs.org/faqs/C-faq/faq/ 11.12a: What's the correct declaration of main()? A: Either int main(), int main(void), or int main(int argc, char *argv[]) (with alternate spellings of argc and *argv[] obviously allowed). See also questions 11.12b to 11.15 below. References: ISO Sec. 5.1.2.2.1, Sec. G.5.1; H&S Sec. 20.1 p. 416; CT&P Sec. 3.10 pp. 50-51. 11.12b: Can I declare main() as void, to ...

27. int main(void) whatever!    cboard.cprogramming.com

28. int main(void) VS int main()    cboard.cprogramming.com

29. void main(), int main(), argc, argv[]????    cboard.cprogramming.com

I read somewhere it is good etiquette to use int main().....I understand that 'argc' is the number of parameters handed to main(), and 'argv[]' is an array of char pointers to the parameters.......but am still a little confused. Am currently learning C, have written some pretty wicked programs, and about to send them in to be marked. All the example code ...

30. int memCopy(void* , void*, int size)    cboard.cprogramming.com

You're working with raw memory, so use 'unsigned' instead. For speed, don't work with a char unless you have to-- use a long instead. Why copy 1 byte at a time, when you could copy 4? or more (depending on the native word-size of your processor)? Never modify your caller's pointers. Always work with a copy. Check for valid pointers, and ...

31. void or int for main?:)    cboard.cprogramming.com

Hi frequently I see mentioned the fact that we should use int main () and not void main().....the trouble here is that some of us here are doing a distance learning course in c programming....where the course provider frowns upon and deducts marks for using int main ()....unless we are passing a value back to the opsys. I personally use int ...

32. Int main or void main    forums.devshed.com

Newbie question 2: hello again friendz of this forum. I'm learning c and I have got this doubt. I want to know why some people use int main() while some other people use void main(). I wonder which is better to use and why? Also why do we return 0 after a program? When 0 means false ? Shouldn't it return ...

33. void main vs int main    daniweb.com

Just main() means whatever the compiler accepts for it's defaults, are used. A return of int may also be the default of the compiler. int main () with no return should give you an error "function should return a value..." void main() is an error with the newest standards, AFAIK, but not all compilers are up to that standard, yet. Old ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.