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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:25:37+00:00 2026-06-14T14:25:37+00:00

Summary: I’ve been playing with unix terminal a bit lately and decided to to

  • 0

Summary:
I’ve been playing with unix terminal a bit lately and decided to to build a tiny Objective-C app in order to test how passing arguments to “main” will actually execute. I’ve build the app keeping std=c99 in mind.

The test: everything works fine if I hard code values to argv and argc hence: argv[0] and argv[1] from the first few lines in main.

The problem: If I comment argv[0] and argv[1] out and run my app from the unix terminal the app will never work and that is why I’m wondering if terminal will append any funny characters that I am not aware of —

Here’s a snippet of the code:
1. Note that Dictionary is just a struct
2. Thoughts?

    int main(int argc, char * argv[])
{
    //argv[0] = "prog";
    //argv[1] = "four";

    NSLog(@"request from: %s, entered string: %s, # of arguments: %i", argv[0], argv[1], argc);

    //argc = 2;
    if (argc >= 2)
    {
        if (translate(argv, argc));
        else
            NSLog(@"%s", "Unable to find request in dictionary");
    }
    else
        NSLog(@"insufficient arguments");

    return 0;
}

    BOOL translate(char * search[], int size)
{
    const int buffer = 6;
    Dictionary dic[] =
    {{"one", "1"},
        {"two", "2"},
        {"three", "3"},
        {"four ", "4"},
        {"five", "5"},
        {"six", "6"}
    };

    char * temp = search[size - 1];
    NSLog(@"temp value: %s", temp);

    int i = 0;
    for (; i < buffer; ++i)
    {
        char * temp2 = dic[i].num;
        NSLog(@"steped into for loop - with currect struct value: %s", temp2);

        if (temp == temp2)
        {
            NSLog(@"steped into if stamtement");
            NSLog(@"%s", dic[i].translate);
            return YES;
        }
    }

    return NO;
}
  • 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-14T14:25:38+00:00Added an answer on June 14, 2026 at 2:25 pm

    So one last time…

    You cannot compare strings using ==, because C ain’t JavaScript and == performs a numerical comparison on its operands. Instead of

    if (temp == temp2)
    

    you should write

    if (strcmp(temp, temp2) == 0)
    

    (and re-read a good C tutorial – in a decent one, “tricky” stuff like that is certainly included.)

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

Sidebar

Related Questions

Summary: Setting up Jenkins on OS X has been made significantly easier with the
Summary I have been looking at historical Australian Rules outcomes using excel with an
Summary: I'd like to view my text in vim with a small bit of
Summary It's been while now that I receive emails on a specific work-related domain,
Summary: make invisible app visible again by clicking desktop icon. I have created a
Summary I currently have a NAnt build script that performs a vssget on either
Summary Since the last update of our app was released, many users started complaining
Summary: I want a horizontal row of ImageButtons to scale down evenly to fit
Summary For some reason, git commands don't work the same when I am logged
Summary: I want to display a value (in a text box) stored in another

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.