Click here to Skip to main content
15,914,820 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: regarding creating databse Pin
Richard MacCutchan28-Mar-10 22:58
mveRichard MacCutchan28-Mar-10 22:58 
JokeRe: regarding creating databse Pin
Rajesh R Subramanian28-Mar-10 23:00
professionalRajesh R Subramanian28-Mar-10 23:00 
JokeRe: regarding creating databse Pin
Richard MacCutchan28-Mar-10 23:05
mveRichard MacCutchan28-Mar-10 23:05 
JokeRe: regarding creating databse Pin
LittleYellowBird28-Mar-10 23:43
LittleYellowBird28-Mar-10 23:43 
JokeRe: regarding creating databse Pin
Richard MacCutchan28-Mar-10 23:51
mveRichard MacCutchan28-Mar-10 23:51 
JokeRe: regarding creating databse Pin
CPallini28-Mar-10 23:28
mveCPallini28-Mar-10 23:28 
GeneralRe: regarding creating databse Pin
KingsGambit28-Mar-10 9:57
KingsGambit28-Mar-10 9:57 
QuestionVariables not the same as input file. Pin
Frank Robertson27-Mar-10 18:06
Frank Robertson27-Mar-10 18:06 
I am currently working on a project for a class, and what I need to do is make a .txt file with a letter on the first line and two two-digit numbers on the second line, and have it write to another text file what the ASCII code for the letter and add and multiply the two numbers.

I've been able to get the code to compile, but it prints out strange numbers instead of what the answers should be. I've been told to initialize my variables, but when I set them to 0, thats all the program reads. So I get a file like, the ASCII is 0, and 0 + 0 = 0, and the like.

Here is the code. Please tell me where I am messing up!

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()

{
ifstream inFile;
ofstream outFile;

char letter1;
double num1;
double num2;

inFile.open("input.txt");
outFile.open("answers.txt");

inFile >> letter1 >> num1 >> num2;
outFile << "The ASCII value of your character: " << letter1<< " is " << static_cast<int>(letter1) <
AnswerRe: Variables not the same as input file. Pin
Garth J Lancaster27-Mar-10 21:14
professionalGarth J Lancaster27-Mar-10 21:14 
AnswerRe: Variables not the same as input file. Pin
Richard MacCutchan28-Mar-10 1:32
mveRichard MacCutchan28-Mar-10 1:32 
GeneralRe: Variables not the same as input file. Pin
Frank Robertson28-Mar-10 2:56
Frank Robertson28-Mar-10 2:56 
GeneralRe: Variables not the same as input file. Pin
Richard MacCutchan28-Mar-10 4:30
mveRichard MacCutchan28-Mar-10 4:30 
QuestionLNK2001 and LNK2019 errors Pin
Krzysiaczek9927-Mar-10 15:17
Krzysiaczek9927-Mar-10 15:17 
AnswerRe: LNK2001 and LNK2019 errors Pin
Adam Roderick J27-Mar-10 17:43
Adam Roderick J27-Mar-10 17:43 
AnswerRe: LNK2001 and LNK2019 errors Pin
Tim Craig27-Mar-10 17:51
Tim Craig27-Mar-10 17:51 
GeneralRe: LNK2001 and LNK2019 errors Pin
Krzysiaczek9927-Mar-10 21:44
Krzysiaczek9927-Mar-10 21:44 
AnswerRe: LNK2001 and LNK2019 errors Pin
Richard MacCutchan28-Mar-10 1:38
mveRichard MacCutchan28-Mar-10 1:38 
GeneralRe: LNK2001 and LNK2019 errors Pin
Krzysiaczek9928-Mar-10 3:32
Krzysiaczek9928-Mar-10 3:32 
GeneralRe: LNK2001 and LNK2019 errors Pin
Richard MacCutchan28-Mar-10 4:33
mveRichard MacCutchan28-Mar-10 4:33 
GeneralRe: LNK2001 and LNK2019 errors Pin
Krzysiaczek9928-Mar-10 4:49
Krzysiaczek9928-Mar-10 4:49 
GeneralRe: LNK2001 and LNK2019 errors Pin
Richard MacCutchan28-Mar-10 4:53
mveRichard MacCutchan28-Mar-10 4:53 
GeneralRe: LNK2001 and LNK2019 errors Pin
Krzysiaczek9928-Mar-10 5:29
Krzysiaczek9928-Mar-10 5:29 
GeneralRe: LNK2001 and LNK2019 errors Pin
Richard MacCutchan28-Mar-10 5:59
mveRichard MacCutchan28-Mar-10 5:59 
GeneralRe: LNK2001 and LNK2019 errors Pin
Krzysiaczek9928-Mar-10 8:07
Krzysiaczek9928-Mar-10 8:07 
GeneralRe: LNK2001 and LNK2019 errors Pin
Richard MacCutchan28-Mar-10 11:34
mveRichard MacCutchan28-Mar-10 11:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.