How to write a / into a file

Jan 13, 2018 at 3:53am
I'm writing a program that converts numbers, letters, and certain symbols to morse code, then writes them to a file. I've gotten everything but spaces to convert and write to file appropriately. Spaces are supposed to write as a / .
Here is my code to write a space to file as a / .


if(fname[i] == ' ')
filename << " / ";
Last edited on Jan 13, 2018 at 5:26am
Jan 13, 2018 at 5:45am
1
2
3
4
5
6
7
std::ifstream fout( filename ) ; // open the file for input
// note that filename is the name of (the path to) the file; fout is the stream that we write to 

// ... 

if( text[i] == ' ' ) // if the character at position i in the text is a space
    fout << '/' ; // write the single character '/' to the file stream 
Jan 14, 2018 at 4:35am
It's still not working but that code seems right. Thanks for your help though.
Topic archived. No new replies allowed.