Linked Questions
24 questions linked to/from Returning string from C function
1 vote
1 answer
33k views
How to make return char function in c programming? [duplicate]
I'm Trying to do some simple c programming that will return the char value. The program is running with no error but, the output of the expected string does not appear. What I expected it will return ...
0 votes
1 answer
3k views
Function to return a string in C. Why this return null? [duplicate]
How can i return a string for work with? I dont know why this function arent working. #include <stdio.h> char* test(){ char A[100]; scanf("%s", A); printf("A = %s \n", A); return(A)...
-1 votes
2 answers
3k views
"address of stack memory associated with local variable" error when running user-defined function in C [duplicate]
Recentely I've been taking the CS50 2020 course from Harvard University as an introduction to C programming. I'm not very experienced with the language or with coding as a whole, so I'm struggling a ...
0 votes
0 answers
476 views
Return a char * in c and send it as a parameter to another function [duplicate]
I would like to know how can I return a string in c and then send it as a parameter to another funcion. For example, in those functions: This is the function that returns a char *: char * read(){ ...
-4 votes
2 answers
334 views
Unable to return string properly in C++ for some range [duplicate]
I've made one C++ program using pointers and functions to return the reverse of a string. When the range char p[] in the function rev is low like 25 (less than. 145), the output is like ►↕☻ ☺♠♥, it ...
0 votes
1 answer
124 views
How can I return a char* from a char* function [duplicate]
So, I'm trying to return a string from a char* function but I always get this warning: function returns address of local variable [-Wreturn-local-addr], and the string doesn't print to the console. ...
1 vote
2 answers
141 views
Returning String Literal from a function to Another [duplicate]
I am really trying very hard to figure out how to return string from a function to other. Please help me to solve this problem. Returning Password as String from this function: char* password(void) ...
0 votes
0 answers
50 views
Passing string from function to another string C [duplicate]
I am trying to have one function pass an string into a string like this: char taBortTecken(char inputString[]){ //antalBokstaver-1 make sure the string is just the right size. This is working ...
1 vote
0 answers
49 views
return a string after being concantenated using strcpy and strcat [duplicate]
I am trying to build a function that concatenate two strings and return the concatenated string here is my current code const char *myName(); int main(int argc, char *argv[]) { char *myname = ...
0 votes
0 answers
46 views
How to return a bunch of elements in an array C [duplicate]
I am quite new in C so I could not fix it. The code below should take a char array (called Rawpack) and getthesign method should return the 10-19 indexed elements of that array. In python I did it ...
0 votes
0 answers
39 views
Return string C [duplicate]
char *_strreverse(const char *str1){ if (str1 == NULL){ return NULL; } char str[strlen(str1)]; strcpy(str,str1); for (int i = 0; i < strlen(...
145 votes
15 answers
416k views
Returning a C string from a function
I am trying to return a C string from a function, but it's not working. Here is my code. char myFunction() { return "My String"; } In main I am calling it like this: int main() { printf("%s", ...
0 votes
2 answers
11k views
3 Address Code Generation using lex and yacc
I'm trying to generate 3 address code corresponding to basic arithmetic expressions. I haven't worked with lex and yacc tools before much (Newbie) and I'm having trouble understanding the flow of ...
0 votes
3 answers
1k views
isalpha() not working properly
I'm trying to use a for loop to go through two strings character by character and see where they are equal, where they are different, and if so if both are letters than I do one condition, but if one ...
1 vote
1 answer
2k views
two C functions trying to return the first word in a string
I have created the two following functions. The first, eatWrd, returns the first word in a string without any white spaces, and removes the first word from the input string: MAX is a number ...