ASCII | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
0 | tab, \t |
\n |
\r |
|||||||||||||
1 | esc |
|||||||||||||||
2 | space |
! | " | # | $ | % | & | ' | ( | ) | * | + | , | - | . | / |
3 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? |
4 | @ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
5 | P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ |
6 | ` | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o |
7 | p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ | |
8 | € | � |
‚ | ƒ | „ | … | † | ‡ | ˆ | ‰ | Š | ‹ | Œ | � |
Ž | � |
9 | � |
‘ | ’ | “ | ” | • | – | — | ˜ | ™ | š | › | œ | � |
ž | Ÿ |
A | ¡ | ¢ | £ | ¤ | ¥ | ¦ | § | ¨ | © | ª | « | ¬ | |
® | ¯ | |
B | ° | ± | ² | ³ | ´ | µ | ¶ | · | ¸ | ¹ | º | » | ¼ | ½ | ¾ | ¿ |
C | À | Á | Â | Ã | Ä | Å | Æ | Ç | È | É | Ê | Ë | Ì | Í | Î | Ï |
D | Ð | Ñ | Ò | Ó | Ô | Õ | Ö | × | Ø | Ù | Ú | Û | Ü | Ý | Þ | ß |
E | à | á | â | ã | ä | å | æ | ç | è | é | ê | ë | ì | í | î | ï |
F | ð | ñ | ò | ó | ô | õ | ö | ÷ | ø | ù | ú | û | ü | ý | þ | ÿ |
me> cat newline_win.txtIn UNIX, '\n' starts a new line. '\r' can be used to overwrite the previous line if you really want to.
Hello
There!
me> od -t c newline_win.txt
0000000 H e l l o \r \n T h e r e ! \r \n
me> od -t c newline_unix.txtOn Macs, '\r' starts a new line.
0000000 H e l l o \n T h e r e ! \n
me> od -t c newline_mac.txtSo the same text file written on three different machines will contain three different sets of bytes at the end of a line!
0000000 H e l l o \r T h e r e ! \r
Name |
Header |
Open Binary File |
Read Binary Data |
Write Binary Data |
Close File |
C Standard I/O |
#include <stdio.h> |
FILE *f=fopen("foo","rb"); |
int n=fread(buf,4,1,f); |
int n=fwrite(buf,4,1,f); |
fclose(f); |
C++ STL I/O |
#include <fstream> |
std::ifstream s("foo",std::ifstream::bin); |
s.read(buf,4); |
s.write(buf,4); |
/* automatic */ |
UNIX I/O |
#include <fcntl.h> |
int fd=open("demo",O_RDONLY); |
int n=read(fd,buf,4); |
int n=read(fd,buf,4); | close(fd); |
Windows I/O |
#include <windows.h> |
HANDLE h=CreateFile(.....); |
int n=ReadFile(h,buf,...); |
int n=WriteFile(h,buf,...); |
CloseHandle(h); |