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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:30:26+00:00 2026-05-27T05:30:26+00:00

Our assignment is to have a server-client model…. We’re supposed to check for a

  • 0

Our assignment is to have a server-client model….

We’re supposed to check for a command line arg, if there is not one(argc = 1), we set up as a server. otherwise we use the argv[1] to setup the client socket…

It seems to run fine if I just use randomness for the argument, but when I try to put an address in, 1.2.3.4 for example, it doesnt give any output, just starts the program and does nothing.

I guess my question is what’s the best way to handle a command line argument in the form of an IP address.

Here is my main function.

int main( int argc, char *argv[] )
{

    printf("%i",argc);
    if(argc==1)
    {
            printf("Welcome to the ZOG Virtual Probe Game!  You have choosen to take the role of a server.");
            printf("\nPlease wait for an opponent to connect.");
            runServer();
    }else if(argc==2)
    {
            printf("Welcome to the ZOG Virtual Probe Game!  You are now connecting to specified IP.");
            runClient(argv[1]);
    }else
    {
            printf("You used an invalid command line argument. You can input an IP address or leave no command arg to host a game.");
    }
}
  • 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-27T05:30:26+00:00Added an answer on May 27, 2026 at 5:30 am

    Add an fflush after the printf. Your welcome message is being buffered. It may be sufficient to just put a newline at the end of the strings being printed.

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

Sidebar

Related Questions

We have just started our new assignment - web-based project. Before I get directly
I have been given an assignment to drop one of our product's dll and
Here is my problem: In our term there are two java courses. we have
I have to use SQLPLUS for my database class, and our first assignment is
In my assembly language class, our first assignment was to write a program to
We just got our first major Perl CGI assignment in my CS class. Our
Our application is interfacing with a lot of web services these days. We have
I suspect I have corrupt mergeinfo but I'm not sure. Does anyone know how
My new assignment at work is to create a second version of our existing
We are currently in the process of upgrading our rails version and I have

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.