I am new to C and I am totally confused by various open/read/write files calls.
for example, to open a file, it seems I can do open & fopen, to get some input from a file, I can do fgetc, fread, fgets, etc.
Could you please explain open/read/write in details? I'd like to know the most popular way to do open/read/write in C.
Let's suppose I need to read from a file (does text or binary matter?), with a buffer size of 4 bytes, print the content of the buffer byte by byte,
i.e I read 16-bit info and display (decimal) value represented by each byte (#1-#4, ... ... #13-#16 bits), say, I read 0000 0000 0000 002A, it will print that the 1st/2nd/3rd quater of the buffer is 0, and the last is 42 (HEX 2A=DEC 42) )in monitor (in string, which is human readable, and in HEX, respectively),
then write values just read into another file.
Pls highlight key points to
1) open file (construct a file pointer or file descriptor? why?)
2) read in buffer
3) read & get byte's value in the buffer (a buffer has 4 bytes), and represent it in HEX, OCX, DEC, or in string
4) write to file