All CUDA API functions return an error code (or cudaSuccess if no error occured). All other parameters are passed by reference. However, in plain C you cannot have references, that’s why you have to pass an address of the variable that you want the return information to be stored. Since you are returning a pointer, you need to pass a double-pointer.
Another well-known function which operates on addresses for the same reason is the scanf
function. How many times have you forgotten to write this &
before the variable that you want to store the value to? 😉
int i; scanf("%d",&i);
Related Posts:
- How to properly malloc for array of struct in C
- difference between
and - Incorrect checksum for freed object on malloc
- Difference between sizeof(char) and sizeof(char *)
- How to allocate array of pointers for strings by malloc in C?
- realloc(): invalid next size when reallocating to make space for strcat on char *
- malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))
- Difference between malloc and calloc?
- Process finished with exit code 11 | Error during malloc [duplicate]
- Incompatible implicit declaration of built-in function ‘malloc’
- Need more information about Aborted (core dumped)
- When and why to use malloc?
- What is the cause of flexible array member not at end of struct error?
- waitpid, wnohang, wuntraced. How do I use these
- How to initialize array to 0 in C?
- How to do scanf for single char in C
- Sign extend a nine-bit number in C
- Warning: assignment from incompatible pointer type
- Break statement not within loop or switch in C
- How do malloc() and free() work?
- Cache Simulator in C
- C: error: expected ‘)’ before ‘;’ token
- Where is the C auto keyword used?
- How to run valgrind with basic c example?
- make: Nothing to be done for `all’
- Data argument not used by format strings in C
- execv vs execvp, why just one of them require the exact file’s path?
- expected expression before ‘{‘ token
- Setting std=c99 flag in GCC
- C Vector/ArrayList/LinkedList
- Convert char array to a int number in C
- Bind failed: Address already in use
- Warning/error “function declaration isn’t a prototype”
- What is the difference between %f and %lf in C?
- Returning an array using C
- warning: initializer element is not computable at load time
- What is stdin in C language?
- Memory Clobbering Error
- How to prevent multiple definitions in C?
- How to pass 2D array (matrix) in a function in C?
- malloc: *** error: incorrect checksum for freed object – object was probably modified after being freed
- error: ‘for’ loop initial declarations are only allowed in C99 mode [duplicate]
- How can you print multiple variables inside a string using printf?
- c – warning: implicit declaration of function ‘printf’
- Flushing buffers in C
- What are 0x01 and 0x80 representative of in C bitwise operations?
- How to make parent wait for all child processes to finish?
- Undefined Reference issues using Semaphores
- What is time(NULL) in C?
- C dynamically growing array
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- How to compile makefile using MinGW?
- Mapping a numeric range onto another
- Why are hexadecimal numbers prefixed with 0x?
- Uninitialized value was created by a heap allocation
- Portable way to check if directory exists [Windows/Linux, C]
- Allocating string with malloc
- OpenGL — GL_LINE_LOOP —
- too many arguments for format [-Wformat-extra-args]
- How to use EOF to run through a text file in C?
- Valgrind complains with “Invalid write of size 8”
- Expression must be a pointer to a complete object type using simple pointer arithmetic
- How to copy a char array in C?
- Simple way to check if a string contains another string in C?
- What does “request for member ‘*******’ in something not a structure or union” mean?
- cast to pointer from integer of different size, pthread code
- Invalid type argument of unary ‘*’ (have ‘int’) Error in C
- Segmentation fault (core dumped) due to fgets – I think
- Why do I get “cast from pointer to integer of different size” error?
- C subscripted value is neither array nor pointer nor vector when assigning an array element value
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Unknown ending signal when using debugger gdb
- Valgrind: invalid read of size 4 -> sigsegv, works fine without valgrind and in visual studio
- error: too few arguments to function `printDay’ (C language)
- How to convert integer to char in C?
- Is there a good Valgrind substitute for Windows?
- Where to find the complete definition of off_t type?
- struct has no member named
- Valgrind Invalid free() / delete / delete[] / realloc() in C
- Difference between “move” and “li” in MIPS assembly language
- printf not printing to screen
- Initializing array of structures
- Still Reachable Leak detected by Valgrind
- How to empty a char array?
- Assembly x86 – “leave” Instruction
- What is the difference between array and enum in C ?
- Undefined reference to main – collect2: ld returned 1 exit status
- How can one see content of stack with GDB?
- What is signed integer overflow?
- What does the term “empty loop” refer to exactly in C and C++?
- When to use const char * and when to use const char []
- Is there a way to have printf() properly print out an array (of floats, say)?
- What do numbers using 0x notation mean?
- What integer hash function are good that accepts an integer hash key?
- Can I create an Array of Char pointers in C?
- Proper way to empty a C-String
- Does stack grow upward or downward?
- Convert Little Endian to Big Endian
- malloc(): memory corruption
- How do you allow spaces to be entered using scanf?