For a homework I was supposed to create a program in c++ (has to work in g++ )to output some ascii art in a txt file. It works perfectly in Visual Studios, but when I compile g++ using cygwin I just get a single line. Am I not supposed to just do cout<<"somecharacerhere"<<endl; ?
1). Part of the code for outputting a square ascii art ( rest follows similar format)
void art(string characters,int height, string shape,string filename){
int i,j=0,k; //looping variables
int length = characters.size();
ofstream ascii;
ascii.open(filename.data());
const string stars(height,'*'); // first and last line are purely stars
if (shape=="square"){ // the width or the number of characters in each line is equal to the height
ascii<<stars<<endl;
for(i=0;i<height-2;i++){
ascii<<"*";
//since it is a square the number of characters(minus the stars) per line is always height -2
I'm just taking a wild guess here, since I've never used Cygwin to compile anything for practical purposes, but it's possible that the Cygwin runtime is leaving newlines unconverted. When you send a newline to the output stream (character code 10) the runtime is supposed to convert the sequence to one the host can directly understand. Newlines under Windows are CRLF (a 13 followed by a 10), while in Unix they're just LF (10). Since Cygwin is supposed to emulate a Unix environment to some extent, this is a possible explanation.