How to write a / into a file

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
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 
It's still not working but that code seems right. Thanks for your help though.
Topic archived. No new replies allowed.