[quote]Can I know if i could do the user input challenge like this(challenge no.2)?
[code]
… #import <readline/readline.h>
int main (int argc, const char * argv[])
{
printf (“Where should I start counting?”);
int i;
for (i = 42; i >= 0; i -= 3) {
printf ("%d\n", i);
if (i % 5 == 0) {
printf (“Found one!”);
}
}
return 0;
}[/code]
[/quote]
The the statement which gets the input from the user is missing.
...
int main (int argc, const char * argv[])
{
// Prompt for input
printf ("Where should I start counting?");
const char * input = ...
const int startFrom = stringToInt (input);
...
Also, you will make it easier for humans if you pretty-format your code and post it between the code tags like this:
#include <stdio.h>
#include <stdlib.h>
#import <readline/readline.h>
int main (int argc, const char * argv[])
{
// Prompt for input
printf ("Where should I start counting?");
// Get the input
...
const int startFrom = ...
int i;
for (i = startFrom; i >= 0; i -= 3) {
printf ("%d\n", i);
if (i % 5 == 0) {
printf ("Found one!");
}
}
return 0;
}