Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8411243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:23:14+00:00 2026-06-10T00:23:14+00:00

Is it possible to return a char Pointer even the calling function is not

  • 0

Is it possible to return a char Pointer even the calling function is not in the same file…. if I call the function for example:

 void gotest(sqlite3 *pt,char *nutzers)
{
    char string[1064];
    char *text;
    text = get_data_byName(pt,"whatever",string);   
    printf("test %s \n\n\n same file",text);    
}

 char *get_data_byName(sqlite3 *ptr,char *user,char *resulter)
{
    .......
    resulter = "TestCall";
    return resulter;
}

if gotest(sqlite3 *pt,char *nutzers) and char *get_data_byName(sqlite3 *ptr,char *user,char *resulter) are in different files then gcc gives the following

Assignment makes pointer from integer without a cast

if I have both functions in one file everything works fine.

compiling like:

gcc -o test test.c time.c database.c libircclient-1.6/src/libircclient.o -lsqlite3 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:23:15+00:00Added an answer on June 10, 2026 at 12:23 am

    You need headers for your files. If GCC doesn’t see a function prototype in the file it’s used in, GCC assumes that the function returns an int. You need to read up on headers. In the mean time, putting this in the file where you use get_data_byName will be enough:

    char *get_data_byName(sqlite3 *ptr,char *user,char *resulter);
    

    You have to remember that although when GCC is linking, it knows that you define get_data_byName, when it’s compiling, it needs to know what parameters and return values it has. That’s the purpose of a header. Headers contain function prototypes. A function prototype looks like this:

    char *get_data_byName(sqlite3 *ptr,char *user,char *resulter);
    

    If you put the prototypes of all of the functions defined in one .c file in one .h file, and them #include that header in the files that use the function, you wont get that error anymore. So if you have a file called get_data_by_name.c, this would be get_data_by_name.h:

    #ifndef GET_DATA_BY_NAME_H
    #define GET_DATA_BY_NAME_H
    char *get_data_byName(sqlite3 *ptr,char *user,char *resulter);
    #endif
    

    Then just #include it in the file that uses get_data_byName:

    #include "get_data_by_name.h"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to pass the pointer of a std::string to a function which
Is it possible to have a function or macro to return variable type? I
Possible Duplicate: Why no switch on pointers? int main(int argc, char** argv) { void*
Possible Duplicate: Calling class method through NULL class pointer #include <iostream> using namespace std;
The documentation for ref() mentions several possible return values. I understand most of them,
Possible Duplicate: return AJAX callback return I have made a JQuery code using AJAX,
Possible Duplicate: Return value from thread I want to get the free memory of
Is it possible to return a stream which is part of a complex object
Is is possible to return two values from a WebService to jQuery. I tried
Is it possible to return a 307 Temporary Redirect from a controller in ASP.NET

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.