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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:50:15+00:00 2026-06-03T04:50:15+00:00

Please bear with me. I am new to C altogether, let alone Objective C.

  • 0

Please bear with me. I am new to C altogether, let alone Objective C. I am trying to do something that should be simple however its not working. I am scanning a string of numbers that also contains symbols. As the mini function runs through the input string it appends numbers to a new string until it comes across an operator (I’m writing a calculator in my own way as a learning exercise.) Right now I am just doing the beginning part and scanning the string and appending character. Here is my code:

char userInput[99];
NSMutableString *number = nil;
int i;

printf( "Please enter math: " );
scanf( "%s", userInput );
fpurge( stdin );

NSString *InputString = [NSString stringWithUTF8String:userInput];

for (i=0; i < [InputString length]; i++) {
    char current = [InputString characterAtIndex:i];
    if (isalnum(current)) {
        [number appendString:[NSString stringWithCharacters:&current length:1]];
        NSLog(@"%@ ", number);
    }
}

For the life of me I can not seem to figure out why it keeps printing 2012-05-02 19:23:20.935 CALC[1447:403] (null) instead of the number value for each number it comes across. So for example if there are 5 numbers in the entered string it will print that 5 times.

  • 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-03T04:50:17+00:00Added an answer on June 3, 2026 at 4:50 am

    You never initialized number–so when you call -appendString: on it, you’re only appending to nil, and the result is just nil back. Try this for your second line:

    NSMutableString *number = [NSMutableString string];
    

    Now number is an empty string object, which is very different from being nil, which is no object at all.

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

Sidebar

Related Questions

Please bear with me, I'm new at C and I'm trying to program an
I am brand new to javascript so please bear with me. I am trying
I'm new to Jquery, so please bear with me. I'm trying to create a
I'm new to jQuery, so please bear with me. I'm trying to make my
I'm kind of new to this so please bear with me... Let's say I
New to MySQL, so please bear with me. I'm working on a project that
I am new to HornetQ so please bear with me. Let me first tell
I am new to C++ so please bear with me. I am trying to
I'm new to OOP, so please bear with me if this is a simple
I'm new to both git and unix so please bear with. I'm trying to

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.