Hmm puse un código de conversión y compilarlo abro el msdos. Cpp y el tipo I en número y se cierra automáticamente dos...su supuesto convertir el código heh
Tiempo para aprender C + +.
Por un lado, la ventana se cerrará. Usted se supone que no sólo haga doble clic en él. Es un programa de ejecución de línea de comandos.
Para hacerle saber:
#include <stdio.h> //Deprecate header file, use #include <cstdio>
#include <iostream.h> // Deprecate header file, use #include <iostream>
//Since you should use #include <iostream>, you are required to put the using namespaces directive
//afterwards so it would be 'using namespace sdt;' under the #includes
int main(int nNumberofArgs, char* pszArgs[])//The arguements arn't required when you arn't accepting arguments in the program
{
int nCelsius;
cout << "Enter the temperature in Celsius:"; //no where in the program do you use << endl;. This means
//the buffer never gets flushed. You should atleast use << endl; when you want a line to end
cin >> nCelsius; //fine for now, but you'll want to move to getline() eventually
int nFactor;
nFactor = 212 - 32; // fine but could be combined into 1 statement.
int nFahrenheit;
nFahrenheit = nFactor * nCelsius/100 + 32;
cout << "Fahrenheit value is:";
cout << nFahrenheit;
return 0; // return 0 is NOT required and shouldn't be used in C++ for the funciton main().
//main() will ALWAYS return an int and 0, so you can elide return 0;
}
- #include <stdio.h> //Deprecate header file, use #include <cstdio>
- #include <iostream.h> // Deprecate header file, use #include <iostream>
- //Since you should use #include <iostream>, you are required to put the using namespaces directive
- //afterwards so it would be 'using namespace sdt;' under the #includes
- int main(int nNumberofArgs, char* pszArgs[])//The arguements arn't required when you arn't accepting arguments in the program
- {
-
- int nCelsius;
- cout << "Enter the temperature in Celsius:"; //no where in the program do you use << endl;. This means
- //the buffer never gets flushed. You should atleast use << endl; when you want a line to end
- cin >> nCelsius; //fine for now, but you'll want to move to getline() eventually
- int nFactor;
- nFactor = 212 - 32; // fine but could be combined into 1 statement.
- int nFahrenheit;
- nFahrenheit = nFactor * nCelsius/100 + 32;
- cout << "Fahrenheit value is:";
- cout << nFahrenheit;
- return 0; // return 0 is NOT required and shouldn't be used in C++ for the funciton main().
- //main() will ALWAYS return an int and 0, so you can elide return 0;
- }
Versión revisada de su código:
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
int nCelsius;
cout << "Enter the temperature in Celsius: ";
cin >> nCelsius;
int nFactor = 212 - 32;
int nFahrenheit = nFactor * nCelsius/100 + 32;
cout << "Fahrenheit value is: " << nFahrenheit << endl;
system("PAUSE");
}
- #include <cstdio>
- #include <iostream>
- using namespace std;
- int main()
- {
-
- int nCelsius;
- cout << "Enter the temperature in Celsius: ";
- cin >> nCelsius;
- int nFactor = 212 - 32;
- int nFahrenheit = nFactor * nCelsius/100 + 32;
- cout << "Fahrenheit value is: " << nFahrenheit << endl;
- system("PAUSE");
- }
Vea cómo mucho más limpio que es? Además, si usted no desea transversal los directorios en línea de comandos para ejecutar el programa de línea de comandos, #<cstdio> incluir en su programa, a continuación, el uso del sistema ( "PAUSE"); en el código cuando se desea que el programa se detenga para que pueda ver la salida.
Yo recomiendo usar un nuevo libro y tal vez encontrar un nuevo tutorial en línea, que suele ser difícil de encontrar.
BTW lo difícil que es C + + para aprender: / lol para un niño de 16 años que es.
C + + es un idioma fácil. Una vez que aprender la sintaxis, no es difícil. Algunos códigos pueden parecer complejas como el infierno, pero por lo general no es, y una vez que tener una idea de las cosas, usted puede entender.
C + + es realmente uno de los idiomas más fácil.