I am having a small issue I have to use only putchar and get char to get an operator and two numbers and print the format into
num1 (operator) num2

I have a lot of code but I am afraid to post on the site because someone might steal it feel free to PM me for my info

I actually had a bad experience with that when A classmate stole my work turned it in and i got in trouble :(

I actually had a bad experience with that when A classmate stole my work turned it in and i got in trouble :(

I'm sorry that you had this experience.

But it's going to be awfully difficult for anyone here to help without some code to look at. At least provide more specific information on your issue with a minimal amount of code that demonstrates your problem.

i will gladly pm u the code the problem is I have to enter the code as follows
(spaces)(num1(spaces)(operand either :+-%/*)(spaces) (num2)
I get my first function by doing

int makenum(void)
{
int digit, num1=0,opperator=0;
while (( digit = getchar() ) !='/n')
{
	if ((digit>='0') && (digit<='9'))
	{
		num1= num1 * 10 + (digit - '0');
		if /*((digit == '*') ||(digit == '/') ||(digit == '-') ||(digit == '+') ||(digit == '%'))*/(digit = ' ')
			 break;
	}
}
return (num1);
}

no matter what i try for the second operand or the second num I fail...
although i just came up with this

do another while loop for second num, and then from there open an if statement that says if operand then another if statement inside that says getchar save that getchar as a digit and retrn t, would that work?

Put the digits into a char string. When you get a non-number. convert the digits using a function such as atoi() . Copy the operator to another variable.

We are only allowed to use getchar and putchar string handeling functions

Set a value to 0.
Then when you read a number, subtract 0x30 from it which converts it to a binary digit .
Now multiply value by 10 and add the digit .

num1= num1 * 10 + (digit - '0') isnt that doing the same thing in my program?

This article has been dead for over six months. Start a new discussion instead.