Hi, just having trouble with my hex adder.
It will have to do several things first of which is to add two hex numbers together.
It is read in with scanf as you will see below then I am going to use several if statements to achive the different functions of my adder.
However i have run into a problem or two.
First of all when i read my hex numbers in with scanf.. should i declare these as integers or a char array?
Secondly why am i getting this error :
C:\DOCUME~1\nlpa58\Desktop\ass2: In function `int main()':
C:\DOCUME~1\nlpa58\Desktop\ass2:12: warning: format argument is not a pointer (arg 2)
C:\DOCUME~1\nlpa58\Desktop\ass2:15:12: warning: multi-character character constant
C:\DOCUME~1\nlpa58\Desktop\ass2:15: error: incompatible types in assignment of `int' to `char[80]'
Failure
here is my code at the moment im only trying to get the add function to work so that i know im reading in my hex numbers right etc..
any help would be appreciated.Code:#include <stdio.h> int num1; int num2; char opp[80]; int result; int main() { //prompt printf ("Type in an expression: "); scanf ("%x %s %x", &num1, opp , &num2); //if loops for the bitwise operators if (opp = 'add'){ result = num1 + num2; } //test printf ("%x", result); }



LinkBack URL
About LinkBacks




