2nd Edition challenge: User Input

i have tried it does not work

If you’re getting an “Undefined symbol” error on readline, select your project in the Project Navigator and under the Build Phases tab in the Link Binary with Libraries section add the libreadline.tbd library. It doesn’t work perfectly - I’m getting every typed character printed twice in the terminal - but it does work.

Also, if you’re cutting & pasting the code from Vitaly’s post, the forum turned the -- in the for loop into an em dash, so you need to change that back.

i am doing this for fun no idea where you put the 42??? vhanks

doing this for fun no idea where you put the 42 thanks

whee do you put the 42 ??? thanks i am just doing this for fun

If you look at this image from earlier in the thread, you can see the console window below the editing window on the right. That’s where you get the prompt & enter in the number. It should open up automatically when you run the program & it prints something to the console, but sometimes you have to open it manually. If you press the little blue buttons below where the console window should be, you should be able to get it open.

i tried everything cannot find that console window sorry thanks mario

do i need to modify my code to prompt the user for input i am totally green here thanks

See @JonAult’s post above.

You don’t really need to prompt the user; when it runs, the program waits for input in stealth mode. Just open the console window and enter some input.

However, the code shown below does print a prompt which appears in the console window.

Debug window:

#import <Foundation/Foundation.h>
#import <readline/readline.h>

int main (int argc, const char * argv[]) {
    @autoreleasepool {
        NSLog (@"\n> Enter some input, then hit the return key:");

        const char  * input = readline (NULL);
        NSLog (@"--> %s", input);
    }
    return 0;
}