python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Why do void pointers behave differently in this scenario when passed to functions other than main()?
This works :
int main(){
char *pc[2]={"Hello","Welcome"};
void *p=pc;
char **pt=p;
printf("%s\n",*pt);//Output : Hello
return 0;
}
However this doesn't work :
...
Kode1000
Votes: 0
Answers: 1
Is this a correct way to store different types in the same allocation?
I need to allocate a chunk of memory using malloc and then store multiple values of different plain old data types in there. Is the following a correct way to do it?
#include <cstddef>
#include ...
StableGeneous
Votes: 0
Answers: 1
Cast a variable to void pointer in Julia
In C/C++ we are able to do this:
double my_var = 4.32;
void* my_var_ptr = &my_var;
which results in the my_var_ptr being a void pointer pointing to the memory which stores the value 4.32.
I am tr...
Vangelis
Votes: 0
Answers: 1
C Void Array Traversal
I have a question about coding styles when using void pointers.
This code is modified from code geeks
#include<stdio.h>
int main()
{
int a[2] = {1, 2};
void *ptr = &a;
for(int i=...
Michael
Votes: 0
Answers: 2