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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:46:39+00:00 2026-06-12T21:46:39+00:00

I just recently started learning Objective C, when i run the next program i

  • 0

I just recently started learning Objective C, when i run the next program i get error
“program received signal: “EXC_BAD_ACCESS”
For the code line

 if([*userChoice isEqualToString:@"yes"])

The full code is:

void initGame (void);
void restartGame(void);
void toGoOn(char *playerChoice);


int guess=-1;
int from=-1;
int to=-1;
bool playStatus=true;
bool gameStatus=true;
int answer=-1;
NSString *userChoice[10];

//if true the game is on

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

    @autoreleasepool {

        GuessManager *game=GUESS;  
        NSLog(@"Hello, lets play");
        NSLog(@"Please provide a positive range in which you would like to play");
      do{
          initGame();
          [game setnumberToGuess:from :to];
        do {                       
            printf("Make you guess:");
            scanf("%d", &guess);
            [game setUserGuess:guess];
            [game checkUserGuess];
            if([game getDidIgetIt])
            {
                playStatus=false;               
            } 
            else
            {
                playStatus=true;
            }

        } while (playStatus);
         restartGame();
      }while(gameStatus);  
        printf("Thanks For Playing PanGogi Games! GoodBye");
    }
    return 0;
}





void initGame (void)
{
    printf("from:");
    scanf("%d",&from);
    printf("to:");
    scanf("%d",&to);    
}

void restartGame(void)
{
    printf("Would you like to continue?(yes/no)");
    scanf("%s",&userChoice); 
    //scanf("%d",&answer); 

   // if(answer==1)
    if([*userChoice isEqualToString:@"yes"])
    {
        gameStatus=true;
    }
    else
    {
        gameStatus=false;
    }
}

I understand that its related to the NSString variable userChoice and how its used in
the if, but what i cant find is what am i doing wrong.

Please help 🙂

  • 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-12T21:46:40+00:00Added an answer on June 12, 2026 at 9:46 pm

    You have 3 errors in the code

    1) I think you are getting confused with NSString and C style char array… You just need to use single NSString object to save multi character data..

    NSString *userChoice;   
    

    2) Since you want to input data using scanf, you need a C style character array. scanf won’t work with NSString types.

    char tempArray[10];
    int count = scanf("%s",&tempArray);
    userChoice  = [NSString stringWithBytes:tempArray length:count encoding: NSUTF8StringEncoding];
    

    3) Now you can use NSString directly.. No need for pointer like syntax

    if( [userChoice isEqualToString: @"yes"]){
       .....
       .....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been learning Objective-C and just recently started using classes (instead of having everything
Warning: I just started learning bash recently and trying to do a recursive function
I've recently been learning the MVVM pattern in WPF and just started making my
I'm new to Mono and just started recently. Is mono program are compiled from
I just recently started learning RoR and found that Prototype.js is a default javascript
I've recently started learning C#. I just learned about properties and decided to make
So I just recently started learning about how databases work, how to use SQL
I just recently have started learning about the wonders of **kwargs but I've hit
I've started learning Lisp recently and wanted to write a program which uses gtk
I just recently started learning and using the ADO.NET Entity Framework and ran into

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.