I have a c program that takes in string inputs i want to check if these inputs are binary values how do I go about this?
For example if the user inputs "1001" how can I can I check to see if its binary or not try not to use pointers Please do it in c as well Also do not use the math library
@Mywork so far I converted the string to an integer and used the atoi function Here is the function I am checking the integer with
@ Program Re-explained I am using a scanf function to take in two inputs and I store them as a string THe user is supposed to enter two binary numbers. I then want to check and make sure each on of these numbers are binary. Below are some examples
INput: 101001 100101
Both Stored As String.
Output:function checks and see thats they are both binary
That is a correct way I want it to run. Here is another example
Input:1001hshds101 100101
Both stored as String
Output: Checks both strings and knows that the first string is wrong
//SOme of my work (ignore this for the most part)
int binCheck(long long int input){
int dv;
while(input! = 0){
dv = input%10;
if(dv>1){
return 0;
}
input = input/10;
}
return 1;
}