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

  • Home
  • SEARCH
  • 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 8304685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:54:53+00:00 2026-06-08T17:54:53+00:00

Can anyone explain to me what I don’t understand here please? I am trying

  • 0

Can anyone explain to me what I don’t understand here please?

I am trying to pass the argument as a “string” (i know there are no strings in c) so that I can use that string later with other functions like it’s a file name that has to be passed for example.
But I don’t know why it won’t accept it or what type should it be

#include <stdio.h>

int main ( int argc, char *argv[] )
{
    char *array= argv[0];
    foo(*array);
}

void foo( char *array) 
// notice the return type - it's a pointer
{
    printf(array);
}

thanks alot!

  • 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-08T17:54:54+00:00Added an answer on June 8, 2026 at 5:54 pm

    You should be calling the function like this:

    foo(array);
    

    What you’re doing is dereferencing the pointer, which returns a char, which is the first character in the string.

    Your printf call should also look like this:

    printf("%s", array);
    

    Your entire fixed code should look like the following:

    #include <stdio.h>
    
    void foo(char *array)
    {
        printf("%s", array);
    }
    
    int main ( int argc, char *argv[] )
    {
        // TODO:  make sure argv[1] exists
        char *array= argv[1];
        foo(array);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw some PHP today I don't understand, can anyone explain it to me?
Can anyone explain boost intrusive hooks concept? i don't understand reading the documentation http://www.boost.org/doc/libs/1_47_0/doc/html/intrusive.html
I don't know what the compilar is doing with ++*p; Can anyone explain me
Can anyone explain why here a = [] ? 1 : 2 a will
Can anyone explain to me why there is a dramatic difference in performance between
Can anyone explain to me how to verify mocks if you don't have their
Can anyone explain flags in Go? flag.Parse() var omitNewline = flag.Bool(n, false, don't print
Can anyone explain me this sentence please? The sorting algorithm is a modified mergesort
Can anyone explain which 'import' is universal, so I don't need to write for
Can anyone explain to me why this program: for(float i = -1; i <

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.