Click here to Skip to main content
15,902,492 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralAuthentication Pin
Anthony988721-Jan-04 9:48
Anthony988721-Jan-04 9:48 
GeneralRe: Authentication Pin
Mike Dimmick22-Jan-04 1:38
Mike Dimmick22-Jan-04 1:38 
GeneralVersion info from resources Pin
ExtraLean21-Jan-04 9:32
ExtraLean21-Jan-04 9:32 
GeneralRe: Version info from resources Pin
Jörgen Sigvardsson21-Jan-04 10:01
Jörgen Sigvardsson21-Jan-04 10:01 
GeneralRe: Version info from resources Pin
Blake Miller21-Jan-04 10:04
Blake Miller21-Jan-04 10:04 
GeneralRe: Version info from resources Pin
John R. Shaw21-Jan-04 10:10
John R. Shaw21-Jan-04 10:10 
GeneralRe: Version info from resources Pin
ExtraLean21-Jan-04 10:26
ExtraLean21-Jan-04 10:26 
GeneralWritiing values of a variable to a file Pin
Obsidianick21-Jan-04 8:15
Obsidianick21-Jan-04 8:15 
Alright, I'm still pretty new to c++, and well my final project in programming is due tomorrow, i'm doign alright so far, but I cant get the values of my "right" and "wrong" variables to write to a file. I'll post my whole code so that you can see exactly what I'm doing here, its just a program that takes questions from a text file, puts them out to the screen and keeps track of what the user answers right and wrong, i need to put the users score into a text file and thats what screwing me up, thanks.

#include<iostream.h>
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>

void main()
{
FILE *fp, *fb;
char line[100],ans,name[20],qfile[20];
char extension[5]= ".txt",entadmin;
int x=0,flag=0,y=0;
int right=0, wrong=0;


cout<<"Enter your name \n";
cin>>name;
strcat(name,extension);
fb=fopen(name,"w");

cout<<"What library of questions do you want to open (eg. quest.txt) ? \n";
cin>>qfile;

if((fp=fopen(qfile,"r"))==0){
cout<<"This file does not exist";
exit(0);
}
while(fgets(line,100,fp)!=NULL){
x++;
if(x!=6)
puts(line);

if(((x%6)==0)&&(x>0)){
fflush(stdin);
ans=getch();

if(ans==line[0])
{
cout<<"Right\n";
right++;
x=0;
}
else
{
cout<<"Wrong\n";
y=0;
wrong++;
}
}
}
cout<<",you got "<<right<<" correct, and "<<wrong<<" wrong";
fcloseall();
}

GeneralRe: Writiing values of a variable to a file Pin
John R. Shaw21-Jan-04 9:36
John R. Shaw21-Jan-04 9:36 
GeneralRe: Writiing values of a variable to a file Pin
John M. Drescher21-Jan-04 9:41
John M. Drescher21-Jan-04 9:41 
GeneralSharing data within application Pin
David Crow21-Jan-04 8:02
David Crow21-Jan-04 8:02 
GeneralRe: Sharing data within application Pin
Joe Woodbury21-Jan-04 8:37
professionalJoe Woodbury21-Jan-04 8:37 
GeneralRe: Sharing data within application Pin
Blake Miller21-Jan-04 10:10
Blake Miller21-Jan-04 10:10 
GeneralExporting Device Context to File (GIF/JPG/PNG etc) Pin
Miszou21-Jan-04 6:34
Miszou21-Jan-04 6:34 
GeneralRe: Exporting Device Context to File (GIF/JPG/PNG etc) Pin
Nick Hodapp21-Jan-04 7:33
sitebuilderNick Hodapp21-Jan-04 7:33 
GeneralRe: Exporting Device Context to File (GIF/JPG/PNG etc) Pin
Miszou21-Jan-04 7:45
Miszou21-Jan-04 7:45 
GeneralRemove Pin
Anonymous21-Jan-04 6:20
Anonymous21-Jan-04 6:20 
GeneralRe: Remove Pin
David Crow21-Jan-04 6:55
David Crow21-Jan-04 6:55 
GeneralRe: Remove Pin
Anonymous21-Jan-04 7:28
Anonymous21-Jan-04 7:28 
GeneralRe: Remove Pin
David Crow21-Jan-04 7:56
David Crow21-Jan-04 7:56 
GeneralDrag and Drop from Outlook Pin
Steve Thresher21-Jan-04 5:47
Steve Thresher21-Jan-04 5:47 
GeneralShellOpen Pin
Gary Kirkham21-Jan-04 5:45
Gary Kirkham21-Jan-04 5:45 
GeneralRe: ShellOpen Pin
Antti Keskinen21-Jan-04 5:55
Antti Keskinen21-Jan-04 5:55 
GeneralRe: ShellOpen Pin
Gary Kirkham21-Jan-04 5:59
Gary Kirkham21-Jan-04 5:59 
QuestionHow to threshold an image? Pin
uus9921-Jan-04 5:41
uus9921-Jan-04 5:41 

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.