| | |
help with errors
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2004
Posts: 13
Reputation:
Solved Threads: 0
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void main()
{
ifstream indata;
ofstream outdata;
char name [13][20];
float avg[20];
int sum=0, n, i=0, m,p;
float davg;
char ch;
indata.open("a:nameFile.txt");
if(indata.fail())
{
cout<<"file not open:";
exit (1);
}
while(i<=20)
{
for (i=0;i<20;i++)
indata.getline(name[i],20);
}
for (int k=1; k<=3; k++)
{
indata >> n>>m>>p;
avg[i]=n+m+p/3;
indata.get(ch);
davg = sum/3;
avg[i] = davg;
sum=0, n=0, davg=0, i++;
indata.ignore();
}
cout<<"enter a grade value:\n";
cin>> n;
outdata.open("outfile.txt", ios::out);
for(int k=0; k<20; k++)
{
if(avg[k]>=n)
outdata<<name[k]<<" "<<avg[k]<<endl;
outdata.close();
}
}
#include <string>
#include <fstream>
using namespace std;
void main()
{
ifstream indata;
ofstream outdata;
char name [13][20];
float avg[20];
int sum=0, n, i=0, m,p;
float davg;
char ch;
indata.open("a:nameFile.txt");
if(indata.fail())
{
cout<<"file not open:";
exit (1);
}
while(i<=20)
{
for (i=0;i<20;i++)
indata.getline(name[i],20);
}
for (int k=1; k<=3; k++)
{
indata >> n>>m>>p;
avg[i]=n+m+p/3;
indata.get(ch);
davg = sum/3;
avg[i] = davg;
sum=0, n=0, davg=0, i++;
indata.ignore();
}
cout<<"enter a grade value:\n";
cin>> n;
outdata.open("outfile.txt", ios::out);
for(int k=0; k<20; k++)
{
if(avg[k]>=n)
outdata<<name[k]<<" "<<avg[k]<<endl;
outdata.close();
}
}
•
•
Join Date: Nov 2004
Posts: 108
Reputation:
Solved Threads: 3
Code Tags
1. void main() is wrong.
1. void main() is wrong.
Join me on IRC:
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
You want help with errors yet you don't use code tags and you don't tell us what the errors are. All I get when I compile are warnings that suggest inaccurate behavior. These statements:
Should be changed to this:
This forces the expression into the float range so that anything past the radix is not truncated as it would be using integer math.
C++ Syntax (Toggle Plain Text)
avg[i]=n+m+p/3; davg = sum/3;
C++ Syntax (Toggle Plain Text)
avg[i]=n+m+p/3.0f; davg = sum/3.0f;
I'm here to prove you wrong.
![]() |
Similar Threads
- News Story: Are You Vulnerable to These Top 25 Coding Errors? (Network Security)
- Simple Programming Errors (Computer Science)
- confused with errors in c++ (C++)
- Loader.EXE and IEDLL.EXE errors (Web Browsers)
- Errors during scandisk (Windows 95 / 98 / Me)
- Upgrading Xp Home to Pro - ERRORS! (Windows NT / 2000 / XP)
- strange annoying errors (Windows NT / 2000 / XP)
- w2k server errors (Windows NT / 2000 / XP)
- Two Problems- "Page Cannot Be Displayed" Errors, Z (Windows NT / 2000 / XP)
Other Threads in the C++ Forum
- Previous Thread: Stacks in C++
- Next Thread: sorry I'm so dumb at this
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count data database delete deploy developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






