-
May 12th, 2014, 03:06 AM
#1
[Beginner] Code not compiling, library issues??
This is just the beginning of my code. My intention is for the user to input a value of scientific notation, then have the program store that as string scientificNotation. I then am trying to have the code define component.mant as the string before the 'E', and component.exp for the string after.
ERRORS:
31 expected primary-expression before '.' token
This error occurs for every instance of structName.structMember (lines 31, 33)
32 `ignore' undeclared (first use this function)
I'm thinking this error is a result of 'ignore' being a part of header <fstream> and the fact that I'm not reading any files?? Or....I'm totally wrong which is likely...
35 expected primary-expression before "readCh"
35 expected `;' before "readCh"
So the program isn't assigning term "component" as struct? Or am I confused about being able to call the global struct by structName?
44 expected primary-expression before "function"
Code:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
using namespace std;
//Global struct
struct component
{
int mant;
double exp;
}sciNote;
//Function Prototypes
void readCharacters
(component& function) //OUT:Data destination
{
string scientificNotation;
cout << "\t\t\tScientific Notation Calculator\n\n";
cout << "Please enter a number in scientific notation.\n";
cout << "For Example: -0.1234E20\n";
getline(cin, scientificNotation, 'E');
cin << component.mant;
ignore.scientificNotation(20, 'E');
cin << component.exp;
component readCh()
{
component function;
return function;
}
}
int main ()
{
readCharacters(component function);
return 0;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|