On the other hand since you are obviously using C++ (from the headers you included, not the code, which is otherwise entirely of the C subset), you could simply use the std::cout object with the << insertion operator so that the magic of operator overloading will select an appropriate output format for you. i.e.:
Note that the "throw all the headers in (and some of them twice) until it works" approach to code development is not recommended! ;-) Your code needs only:
include <cstdlib>
include <stdio.h>
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have not used C for a long time, trying to write something at this moment. With a little issue of using atof:
include <cstdlib>
include <math.h>
include <stdio.h>
include <stdlib.h>
include <iostream>
include <string>
include <cstdlib>
int main(int argc, char *argv[])
{
double n;
char a[6];
}
Here is the output:
tester 1...
n=0
tester 2...
n=0
Press any key to continue . . .
What have I done wrong?
Thanks, cnfmsu
Use the compiler options -Wformat -Werror -Wall, and the compiler will tell you what is wrong.
If you want to see a double, you have to print a double! The 'd' in "%d" does not incidentally stand for "double"!
If your still stuck revise: http://www.cplusplus.com/reference/clibrary/cstdio/fprintf.html
On the other hand since you are obviously using C++ (from the headers you included, not the code, which is otherwise entirely of the C subset), you could simply use the std::cout object with the << insertion operator so that the magic of operator overloading will select an appropriate output format for you. i.e.:
std::cout << std::endl << "tester 1..." << std::endl <<" n=" << n << std::endl ;
Note that the "throw all the headers in (and some of them twice) until it works" approach to code development is not recommended! ;-) Your code needs only:
include <cstdlib>
include <stdio.h>
Clifford
O_o
There is nothing wrong with your use of 'atoi', but plenty wrong besides...
Soma