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 4553112
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:53:58+00:00 2026-05-21T16:53:58+00:00

I haven’t programmed in C for awhile and having an issue with passing a

  • 0

I haven’t programmed in C for awhile and having an issue with passing a string to a function.
The code works however I get warnings from gcc.

I call the function in my main with:

copyToCode(code, section1, section2);

The function is:

void copyToCode (char **code, char *loc, char *data ){}

I get “conflicting types for copyToCode” on the line containing the function and “previous implicit declaration of copyToCode was here” warning on the line calling the function.

I have declared the variables:

char *code = malloc (32*1000* sizeof(char));

char *section1 = malloc(8*sizeof(char)), *section2 = malloc(8*sizeof(char));

I also tried this :
char *section1[8];

As a side question – which is correct?

The section1 and section2 are meant to be Strings, and the code is meant to be an array of strings.

Thanks for reading, I appreciate any help.
Gareth

  • 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-05-21T16:53:58+00:00Added an answer on May 21, 2026 at 4:53 pm

    You need to declare the function before you call it, otherwise the compiler will try to work out what the function prototype is on your behalf.

    The message

    previous implicit declaration of copyToCode

    is telling you this. An implicit declaration is one that the compiler makes because you haven’t yet given it an explicit declaration.


    In your update to the question you say that code is intended to be an array of strings but you define it as:

    char *code = malloc (32*1000* sizeof(char));
    

    That allocates a single string. An array of strings would be held in a char**, just like argv. You would need to allocate the array first, which would contain n strings, each being a char*. Then you’d have to allocate each char* one by one in a loop.

    This sort of coding is so much easier in C++ with the standard library string and vector classes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I haven't worked with SQL Reporting much, however I have been trying to get
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I haven't programmed games for about 10 years (My last experience was DJGPP +
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Haven't really create my own function before, so what I am attempting is to
I haven't taken any database course. Please excuse me... From Django Book tutorial, we
I haven't got any code at the moment but I have a situation where
Haven't fired up reflector to look at the difference but would one expect to
Haven't done ASP.NET development since VS 2003, so I'd like to save some time
Haven't seen many Geneva related questions yet, I have posted this question in the

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.