'Returning a buffer from c function [duplicate]
I have this code:
#include <stdio.h>
int main() {
dosome();
}
char* dosome() {
char* buffer = malloc(sizeof(char) * 128);
gets(buffer);
puts(buffer);
return buffer;
}
I want to return the buffer, so it can be printed, or worked with in the main function in some way. This gives a reutrn type error though I'm aware that gets() is not safe. This is a proof of concept
The error looks as follows simple.c:11:7: error: conflicting types for ‘dosome’ 11 | char* dosome() { | ^~~~~~
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
