Finally wrote the function I wanted to make with help of pass-by-reference.
The code below would allow to load a ASCII file content (hopefully with binary file too) into an uninitialized string.
...
Type: Posts; User: creek23
Finally wrote the function I wanted to make with help of pass-by-reference.
The code below would allow to load a ASCII file content (hopefully with binary file too) into an uninitialized string.
...
Thanks Salem! That was actually helpful. Here's the working code below.
#include <stdio.h>
#include <stdlib.h>
void my_strcpy(char **dest, char *src) {
*dest = (char *)...
Saying there is none and saying you can simulate it is a contradicting statement. Just as saying there no pointers in Java but you can fake one.
Of course, I'm aware that C uses pointers to fake...
already added 1 -> malloc(sizeof(strlen(src) + 1));
still the same. app crashes. :(
I actually just forgot the **. edited the post, please check again.
I'm actually not after the replication of the functionality of strcpy nor strdup. I'm after the passing-by-reference in C.
Exactly how do I do that? I'm getting segmentation fault with this test....
I'm trying to make my own strcpy. A version of strcpy that will allow this,
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char *content1;