John Shaw's Profile

About

 
Points: 11
Gender: Male
Birthday: February 22, 1970
Relationship: In a Relationship
Birthplace: Nottingham (UK)
Current City: Stapleford

Pages

Contact

 

John Shaw
January 5, 2015 · Public

Hi all !!!

Happy New year to you !

Hope you had a great time.

I have a question (probably easily answered) .

So I'm trying to read a txt file that contains

System_Fitted 0
System_Operational 1
System_Damged 2
System_Under_Repair 3
......

my problem is not in reading the file into my program, the problem is extracting the 'int' values.
if I ifstream the file into a string, that's just displayed as a strong (cause that's what it is !)

How do i then :
1. extract the values.
2. assign them to my 'internal' variables ?

System_Fitted
System_Operational
System_Damged
System_Under_Repair


This is going to be a game save / load player info section.

Anybody suggest a way, please !!
I've tried 'pusback' but don't fully understand what's going on (I don't want to use code I don't understand, I, can't seem to find any helpful info on this command either, or for that matter anything on parse ( Which I believe will be very helpful here !))

Thank's in advance

John S.

John Shaw
December 10, 2014 · Public

Can anyone help with 'Passing By Reference'

I'm trying to pass a 'name'

by using in main.cpp
Sometitlte->SetThe_Race_Name("XXXXX");

using my header "Ship.h"

class The_Race_Name

{
public:

int *x;



protected:


private:

string *RACE_NAME;

}


in Ship.cpp


void Vessel_Construction::DisplayStats()

{

cout

John Shaw
October 23, 2014 · Public

Hi all
I'm trying to do s Word count, and a Character count from reading the file ONCE.
My solution was to load the ifstream TWICE (Not what I wanted !!)

Any suggestions, greatly appreciated.

#include // Pre-processor directive
#include // Used for string manipulation
#include // Required to manipulate a file stream
#include // Required for sleep command

using namespace std;

// This Program will Read a txt file, character by character
// and display it on the screen, as though it were being typed by someone
// And tell you how many characters are in the file

int main() // Title of our function (main)

{
int wordCount=0;
int charCount=0; // This will hold our total character count
string words; // This is for reading the file as a string
char chars; // This is for reading the file Character by character


ifstream theFile("Test.txt"); // To read the Data from the file document named "XX.txt"
// Into variable 'theFile'

// Now the While loop, LOOPS through each piece of information and loads it to the appropriate variable
// Those variables are checked by the FILE PIOINTER
// File Pointer starts TOP LEFT of our txt file, it runs fro TOP LEFT to BOTTOM RIGHT through our file

while(theFile>>chars>>noskipws) // While this condition is TRUE the Loop continues
// The 'noskipws' Command, Causes C++ to 'Not Skip White Spaces'
{
cout

John Shaw
October 6, 2014 · Public

I have managed to get lesson 42 working
by including the following in MAIN.CPP

#include "sally.h"

#include "sally.cpp"

is this right?