Question about getline with fstream

  • Thread starter Thread starter yungman
  • Start date Start date
Click For Summary
SUMMARY

The discussion focuses on the use of the getline function with fstream in C++. The user encountered compile errors when attempting to read a file into a string using getline(dataF, Crstr) and found that dataF.getline(Crstr, size) did not work as expected. The conversation also covers the behavior of file.seekg() for random file access, clarifying how the position-in-file pointer operates after read and write operations. Key insights include the distinction between getline() and fstream::getline() and the importance of understanding the position of the file pointer during file operations.

PREREQUISITES
  • Understanding of C++ file I/O using fstream
  • Familiarity with string and character arrays in C++
  • Knowledge of the seekg() function for file positioning
  • Basic understanding of compile errors in C++
NEXT STEPS
  • Review the C++ documentation for getline() and fstream::getline()
  • Explore the behavior of the seekg() function in detail
  • Learn about the position-in-file pointer and its implications in file I/O
  • Investigate common compile errors in C++ and how to resolve them
USEFUL FOR

C++ developers, students learning file I/O operations, and anyone troubleshooting file handling issues in their code.

  • #61
phinds said:
You set a TIME goal. Why not set a LEARNING goal instead?

A time goal without a learning goal can be met just by waiting.
 
  • Like
Likes   Reactions: sysprog
Technology news on Phys.org
  • #62
Vanadium 50 said:
A time goal without a learning goal can be met just by waiting.
Yeah, but he's setting very brief time goals.
 
  • #63
All the faster. :wink:
 
  • Haha
Likes   Reactions: phinds
  • #64
There's the old line "I took a speed-reading class and was able to read War & Peace in twenty minutes. It's about Russia."
 
  • Haha
Likes   Reactions: sysprog
  • #65
Vanadium 50 said:
There's the old line "I took a speed-reading class and was able to read War & Peace in twenty minutes. It's about Russia."
Reminds me of:
1601298941329.png
 
  • Haha
Likes   Reactions: sysprog
  • #66
The question about how file input works has been beaten to death, so this seems like a good place to end the thread.
 

Similar threads

  • · Replies 32 ·
2
Replies
32
Views
4K
Replies
6
Views
1K
  • · Replies 70 ·
3
Replies
70
Views
5K
Replies
20
Views
2K
  • · Replies 118 ·
4
Replies
118
Views
10K
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 33 ·
2
Replies
33
Views
3K
Replies
10
Views
2K