Help with a function

i wrote a function that checks if the user typed in a valid integer number.
the function works perfectly, but there's a little problem:

whenever the user enters an invalid input (any non digit character) - the function returns the value 0.
and if the input is valid (i.e a number - any number) - the function returns it to the main program.
the problem is - 0 is a valid number, so if the user enters 0 or he enters a wrong input - either way - the function will return 0, so the main program can't tell between these two scenarios.
is there a way to overcome this situation?

The standard library function strtol shows one way of overcoming this limitation: give the caller a pointer to the end of the valid input. Then the caller can check whether it coincides with the end of the string (for example, if the whole string was supposed to represent an integer).

Are you quite sure you understand your assignment? Professional footballers aren't required to bind their legs in burlap sacks.

i couldn't agree more.
the idea to define a function to check the input was mine.
the assignment is to write a program that obtain as input an integer number, and prints the fibonacci sequence up to the number given.
for example, if the input is 9, the output should be:
0 1 1 2 3 5 8
if the input is -7, the output is an empty line.

but that's the easy part.
the real pain is that for any input that isn't a valid number, the program should print: "Wrong input!"

Since you did not specify I have assumed that you are using C code and lower-common denominator C89; i.e. no built-in boolean and no reference types. C99 and C++ have features that could improve this code a little.

An alternative is to return a structure that has a validity flag and a value, but that is not really the most appropriate solution in this case.

You could use either INT_MAX or INT_MIN, both highly unlikely input values. The main point in choosing a value to indicate an invalid value is that it be one that should not otherwise appear.

Another thought is that the stricture against pointers should not apply to using them in the parameter list of your function, which is not part of the assignment description. Most programming assignments are designed to have you practice what you have learned in class or in your reading assignments and that is why they will often restrict you from using a different technique. Since your assignment is apparently not supposed to be about other methods for returning certain information from a function, you should be free to use a pointer to return the input value via a pointer and the status as the return value, or vice-versa, especially if you annotate what you are doing and why in your comments and you do not use pointers elsewhere, thus demonstrating that you are conforming to the spirit of the assignment. Discussing this point with your instructor might also help; as I learned early on in military bureaucracy, rules are made to address a specific problem, but can have consequences unforeseen by the writers of those rules -- the same seems to apply to laws. If your problem is an unforeseen consequence of his restrictions, your instructor may give you permission to use a pointer in this one case. If unable to speak with him in order to obtain permission, then there's always the old adage: "Forgiveness is always easier to obtain than permission."

Here's a thought: what are the chances of the user entering the greatest magnitude negative number? Highly unlikely, so why not use that value to indicate wrong input?

This is a really great answer. Integers that are close to the limits of the data type are likely to cause overflow under subsequent manipulation, anyway, so it's hardly a huge loss to sacrifice INT_MIN as an error indicator. Moreover, two's-complement integers already have one more negative value than positive values, and INT_MIN specifically is pathological (for example, -INT_MIN == INT_MIN (the negative of the most negative integer is negative!)), but removing INT_MIN makes everything symmetric.