Tình hình là em ghi vào file theo byte nhưng không biết đọc từ file đó kiểu gì
Code ghi file:
> \#include stdio.h>
> \#include stdint.h>
> struct udphdr {
> uint16_t uh_sport;
> uint16_t uh_dport;
> uint16_t uh_ulen;
> uint16_t uh_sum;
> };
> int main(){
> FILE * fp;
> char udphdr_str[4];
> struct udphdr *uhdr;
> int sport, dport, ulen, checksum;
> uhdr = (struct udphdr *)udphdr_str;
>
> printf("Source port: ");
> scanf("%d", &sport);
> uhdr->uh_sport = sport;
> printf("Destination port: ");
> scanf("%d", &dport);
> uhdr->uh_dport = dport;
> printf("Length: ");
> scanf("%d", &ulen);
> uhdr->uh_ulen = ulen;
> printf("Checksum: ");
> scanf("%d", &checksum);
> uhdr->uh_sum = checksum;
> fp = fopen ("pkt_hdr.txt", "w");
> fwrite(udphdr_str,1,4,fp);
> fclose(fp);
> }
Khi đó khi nhập số thì trong file sẽ ghi thành từng byte kiểu như 
Ò^Dè^@
Bây giờ em muốn đọc file để xuất ra dạng clear text thì không biết dùng lệnh gì được.
Mong các bác chỉ em hướng giải quyết với.
Em cám ơn !

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?