This is a discussion on Assignment HELP!! within the C Programming forums, part of the General Programming Boards category; Originally Posted by cprogrammer22 Cannot get the function to add my numbers.. So at some point you learned to add, ...
yeah i know how to add im having trouble with the function, im not gettin the numbers added when i call it and not sure if i use a for loop or what?
Somethings very fishy here!
Your functions name is "print", but you call something called "printf()":
which should have given you a compiler error a mile wide!Code:printf(string1);//call function to print out information
If you aren't receiving compiler errors, you need to fix that with your compiler. If you *are* receiving compiler errors, you need to pay attention to them.
Fix this, and post up a sample of your input and output, please, so we're all on the same page here.
It looked to me like he meant to call his own function "print", but misspelled it as printf, just out of C syntax habit.
I don't understand why you'd have a note about "//calling the function", in the code, when you were just using printf() to print one char string. BFD.
if i call my original print function wont it print the numbers is reverse order since i did that before? i dont think i have the numbers set up to add correctly. im changing my add function call in main to
It could be a bad habbit - using custom string in printf instead of
which is more stable and thus should be recomended.Code:printf("%s", string1);
But it is not my point - my point was - compiler could not determine the first error because the prototype of the printf was match.
Maximum it could warn about the second issue - but it should be very sofisticated compiler
To be or not to be == true
i cant print out the two numbers i want to add still with the add(p, q);
Vart: I've never seen printf() with just a pointer inside, and no formatting info. If you say it works, that's good enough for me.
This would be the case when the format string has no format specifiers. The pointer is presumably a pointer to the first character of the format string.Originally Posted by Adak
Well - that's just wrong! ROFL!!
Sure Tabstop - start the highly technical, complex arguments. What a pal you are!!