Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
Since printf of a string works with an address in input, why printf does not accept just "argv"
int main(int argc, char **argv){
    printf("argv: %s\n",argv); // does not work and prints random stuff
    printf("*argv: %s\n",*argv); // works and prints ".a.out"

}

I test with:

./a.out nop

My confusion is this:

"argv" variable in the second line has the address of the first char of "./a.out".

"*argv" variable in third line is the first char of "./a.out".

So why printf("argv: %s\n",argv); to only print "./a.out" does not work?

I know that it's wrong, but I don't know why.

enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

argv is a pointer to a pointer. It means it "points" to addresses, not directly to characters.

So at address argv, other addresses are stored, not strings. If you want to access the first string, you have to use the address of it, which is either *argv or argv[0].

I don't know if it's clear enough, don't hesitate to ask for more clarifications.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!