I'm writing a script to check for dos line breaks, in a unix environment. however, I dont have a sample to check my test cases. How do I create one?
2 Answers
fprintf(fp,"something\r\n"); or
data[n++]=0x0D; data[n++]=0x0A; fwrite(data,1,n,fp); or have a program like this
rb=fread(datain,1,sizeof(datain),fpin); if(rb==0) break; rc=0; for(ra=0;ra<rb;ra++) { if(datain[ra]==0x0A) { dataout[rc++]=0x0D; } dataout[rc++]=datain[ra]; } fwrite(dataout,1,rc,fpout); dataout has to be twice as big as datain just in case.
it is far easier just to tell your text editor to do it, open the file then save or save as after changing the format for that file. The scintilla based editors, scite, geany, notepad++, have no problem with it (geany makes it very easy on a document by document basis). looks like vi and probably emacs will work. Textpad no problem.