What the inFile >> S
does is take in the file stream, which is the data in you file, and uses a space delimiter (breaks it up by whitespace) and puts the contents in the variable S.
For example:
If we had a file that had the follow contents
the dog went running
and we used inFile >> S
with our file:
ifstream inFile("doginfo.txt") string words; while(inFile >> words) { cout << words << endl; }
we will get the following output:
the dog went running
The inFile >> S
will continue to return true until there are no more items separated by whitespace.
Related Posts:
- How does ifstream’s eof() work?
- Separating class code into a header and cpp file
- Error at constructor : Expected an identifier?
- Sentinel while loop for C++
- Error “C++ requires a type specifier for all declarations whilst defining methods”
- C++ BlackJack Stuck trying to program Ace
- What are the differences between struct and class in C++?
- Already defined in .obj – no double inclusions
- fatal error LNK1169: one or more multiply defined symbols found in game programming
- How to call a parent class function from derived class function?
- Reading data from file into an array
- When/why to make function private in class?
- Error: invalid use of member in static member function
- C++ equivalent of java’s instanceof
- Easiest way to convert int to string in C++
- pinpointing “conditional jump or move depends on uninitialized value(s)” valgrind message
- C++ equivalent of Java’s toString?
- Is there any built-in factorial function in c++?
- C++ struct constructor
- When to use virtual destructors?
- std::string to float or double
- What is difference between Application Buffer and System Buffer
- C++ undefined reference to defined function
- Logical XOR operator in C++?
- C++ – Decimal to binary converting
- Alternative to itoa() for converting integer to string C++?
- 1e-9 or -1e9, which one is correct?
- Returning an empty string : efficient way in c++
- invalid conversion from ‘const char*’ to ‘char*’
- Evaluate a string with a switch in C++ [duplicate]
- Expected initializer before function name
- Inheriting constructors
- Pass a vector by reference C++
- lvalue required as left operand of assignment – Array
- What is uintptr_t data type
- Why do we use volatile keyword? [duplicate]
- C++ round a double up to 2 decimal places
- Windows 7 exception code: 0xc0000409
- Convert float to std::string in C++
- “items list” or “item list”
- When and why do I need to use cin.ignore() in C++?
- terminate called after throwing an instance of ‘std::out_of_range’
- What does “missing template argument” mean?
- undefined reference to ‘std::cout’
- warning: control may reach end of non-void function
- identifier “string” undefined?
- What does LPCWSTR stand for and how should it be handled with?
- A warning – comparison between signed and unsigned integer expressions
- Difference in make_shared and normal shared_ptr in C++
- VC++ fatal error LNK1168: cannot open filename.exe for writing
- Reading integers from file and store them in array C++ [closed]
- Uninitialised value was created by a stack allocation
- C++ Image Processing Libraries
- Printing the correct number of decimal points with cout
- error C2011: ” : ‘class’ type redefinition
- error: request for member ‘..’ in ‘..’ which is of non-class type
- Socket API or library for C++?
- Initialize empty vector in structure – c++
- C++ catching all exceptions
- error: new types may not be defined in a return type
- How to replace all occurrences of a character in string?
- Deleting an object in C++
- Appending a vector to a vector
- C++ Expression must have pointer-to-object type
- C++ “Access violation reading location” Error
- Getting error: ISO C++ forbids declaration of with no type
- IntelliSense: the object has type qualifiers that are not compatible with the member function
- codingbat-like site for C++
- extra qualification error in C++
- RPN Calculator for C++
- How can I get the list of files in a directory using C or C++?
- Function definition not found for a function declared inside unnamed namespace – how to resolve? (Visual Studio 2015)
- How do I check if a C++ std::string starts with a certain string, and convert a substring to an int?
- How do I get the type of a variable?
- What is the meaning of a C++ Wrapper Class?
- terminate called after throwing an instance of ‘std::out_of_range’ what(): basic_string::substr
- error C2106: ‘=’ : left operand must be l-value
- What does it mean that “a declaration shadows a parameter”?
- error C2601: ‘main’ : local function definitions are illegall – MS VS 2013 Compiler
- std::string length() and size() member functions
- How to convert QString to int?
- Update GCC on OSX
- Which is faster C++ String length() or size()?
- creating an array of structs in c++
- multiple definitions error in c++ and solution to solve this issue
- Function stoi not declared
- Error: member function may not be declared outside of its class.
- Struct inheritance in C++
- How do I simply compare characters in C++?
- How to Check the Version of my gcc?
- Difference between function arguments declared with & and * in C++
- C++ floating point to integer type conversions
- How to get an average in C++?
- C++: variable ‘std::ifstream ifs’ has initializer but incomplete type
- Getting an error “fopen’: This function or variable may be unsafe.” when compling [duplicate]
- The tilde operator in C
- Game Engines that use PHP for scripting?
- Direct way of computing clockwise angle between 2 vectors
- Member function with static linkage
- Conversion from ‘myItem*’ to non-scalar type ‘myItem’ requested