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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:16:22+00:00 2026-06-13T05:16:22+00:00

can anyone point me to the problem over here? This compiles but it won’t

  • 0

can anyone point me to the problem over here? This compiles but it won’t print anything. I need to compare the string from command line argument with the string “hello”.
Thanks!

  #include <stdio.h>
  #include <string.h>

  int main(int argc, char *argv[])
  { 
      if (argc == 0) 
      {
        printf("No arguments passed!\n");
      }

      char *str = argv[1];
      if(strcmp("hello", str)==0)
      {
        printf("Yes, I find it");     
      }

      else
      {
        printf("nothing"); 
      }

    return 0;
  }
  • 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-13T05:16:23+00:00Added an answer on June 13, 2026 at 5:16 am

    My ESP suggests that you’re running this in an interactive editor/debugger, such as Microsoft Studio. You probably haven’t configured the environment to pass any command-line parameters, so you expect to see nothing as your output.

    However, you access argv[1], which does not exist, creating a seg-fault, and the program aborts before there is any output.

    To fix this, check the value of argc first, and make sure you don’t access invalid memory.

    Also, I recommend putting a \n at the end of each printf to help flush any buffered output to the console.

    int main(int argc, char *argv[])
      {
          if (argc == 0) 
          {
            printf("No arguments passed!\n");
          }
          else if(strcmp("hello", argv[1])==0)
          {
            printf("Yes, I find it\n");     
          }
    
          else
          {
            printf("nothing\n"); 
          }
    
        return 0;
      }
    

    When you run this, you should see:

    $prompt:  myprogram
    No arguments passed!
    
    $prompt:  myprogram hello
    Yes, I find it
    
    $prompt:  myprogram world
    nothing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem getting this test case to work. Can anyone point me
I am in way over my head, and am hoping anyone here can help.
Can Anyone point Me in the direction of how to tell when, for example,
Can anyone point me at an example of a customized Google Chrome Frame install
Can anyone point me toward a Go library that will give me the ability
Can anyone point me to some documentation about how I can use an Iso
can anyone point to a site or describe how I can go about designing
Can anyone point me at a decent repository or dependency injection library for any
Can anyone point me to an example on how to use CURRENT_DATE in a
can anyone point me in the direction of a good tutorial on how makefiles

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.