Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I/O redirection

#include<stdio.h>
#include<stdlib.h>

int main()
{
   int i;
   for(i=1; i<=255; i++)
   {
       printf("%d %c\n",i,i);
   }
}

Hey i am working my way out from i/o redirection, and i got stuck in outputting ascii table from command prompt i done this.

C:\New folder\practice> main.exe > temp.txt

C:\New folder\practice> type temp.txt

and after hitting enter (after type temp.txt) it only outputs first 26 numbers. My question is why?

Also can someone explain me how to just copy the code into text file using redirection I know how to do using FILE I/O.

like image 811
Kanishk Tanwar Avatar asked Jan 29 '23 20:01

Kanishk Tanwar


1 Answers

Because you're using MS-DOS... er MS WinDOS, and there ASCII number 26/^Z is the end-of-text-file mark.

The feature exists so that the environment is compatible with the CP/M operating system of the early 1970s, in case you'd need to use some files that originate from that. As you've noticed, only type works like that, but more would display more... (no pun intended).

No kidding.