블로그 이미지
Leeway is... the freedom that someone has to take the action they want to or to change their plans.
maetel

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
  • total
  • today
  • yesterday

Category



Read a file and see the ascii code.
ref. http://www.asciitable.com/

cstdio (stdio.h)
C library to perform Input/Output operations

FILE
Object containing information to control a stream

fgetc

Get character from stream

feof
Check End-of-File indicator


(char)

fopen

fclose

EOF (End-Of-File)
the value returned by several <cstdio> functions to indicate failure, either because the End-of-File has been reached in a reading operation or because an error happened.



Usage of memcpy function in <string.h>
void * memcpy (void * destination, const void * source, size_t num);
struct
    ref. Cprogramming.com Tutorial: Structures


size_t
Unsigned integral type
: the integral data type returned by the language operator sizeof and is defined in the <cstddef> header file (among others) as an unsigned integral type
: It expresses a size or count in bytes.

strcpy


memcpy
Copy block of memory


sizeof



Xcode 실행 결과:
Student: Hong Gil-Dong A: 38 W: 72.0
Student: Hong Gil-Dong A: 38 W: 72.0
\277\377\3660\217\341SH\277\377\366\200\277\377\367�ď\344<\\277\377\366\240���P�����\377\377\217\345&(��������\277\377\366\300�����0\360\220\325ܿ\377\367�\277\377\367�\214\217\341SH\277\377\366\360����\217\341Vp\217\345\305h�\340���P���\217\340V \277\377\366\360\277\377\367�\217\340Vt\217\345�\277\377\367���q
\331��q
\331H���\247!\340�����������\217\345\305h\217\345\305h�\340���P���\217\340\271\364\277\377\367P���P\217ຼ\217\340\250\360\277\377\367PD��"�\340��q
\331H�����\340\227!\340\227!\340���\247!\340���\277\377\370����\217\345\305h�\340��q
\331]\277\377\370�\217\340\333\277\377\370�$��"\217\340\334ܧ\230\200�����0��\217\345\305h��B��"\217\342Nd\217\3406\200����\247\230�\200�\204�\204rs/l��q
\331��q
\331\372-2/build/Deb��������������������\227!\340\227!\340\277\377\370\260\240�\234\247!\340�������\277\377\370�\217\345?����/����\277\377\370\270��\306T��\277\377\370\200�\240\217\345\305h\217\341\374\277\377\370\200"�(\217\341Ts3-2.ob�\247\230�\340\217\340\217<\277\377\370\220D��"�\340\220︿\377\370\240���P\220�L\217\345\305h\277\377\370\260\277\377\371��\303\357����������\260h\217\345\305h��\260h\277\377\370\320��\306T��\364\217\341\374\277\377\370\360\240�\324܏\341
\214\220\324\314������\2520\277\377\372\344\277\377\371X\277\377\372\350\217\3451��\340\217\3401�\277\377\371 �6\350\217\345/\220���\217\345/\220����\340\217\340/\220\277\377\3710�\340\217\34004\217\345V\220����\240���\217\340V\220\277\377\371P����\217\340WH������������\277\377\372\344\277\377\372\360\277\377\372\350����\277\377\372\344\277\377\372\360\277\377\371\200\240�\333H�6\350\220\333H\277\377\371\200����\220�L\277\377\372\360\277\377\372\350���\277\377\372\360��.\344\277\377\371\340����\217\341V\330�6\350�������\277\377\372\344\277\377\372\360\277\377\372\350�\214�6\350\220\333H\277\377\371\340\220\351\220ۤ��\2520�7\330����6\320�������\220�\360��������������������������������\277\377\372\344\277\377\372\360\277\377\372\350���\277\377\372\360��.\344\277\377\372@\277\377\372\350��/��\251\376\376\376\377\200\200\200\200�����������q\376\376\377���\217\340r\244��������\217\340s��������StudentRecord=136
double=8, float=4, int=4, char=1

shell 실행 결과:
Student: Hong Gil-Dong A: 38 W: 72.0
Student: Hong Gil-Dong A: 38 W: 72.0
#[p#####C<##SH###H##~0##~0##############^$###0#######0##^$#####^###H##C<##SH###H###\##~0#L##########################^$####0p##^L##V#######WH#########h###T##########################0p######h0####0(####0##V####@####d###h##~0##~0##~0##~0###0$"#########p###0#####0p###h0####0(#####0
                                       x(܏########"######h##
T#####SH##########SH#######X)@##<\#########h####0 ###P)##SH####M#0####@0p###h########(##T###r###/###/#############0##04000pM#l#######0p##
###V###########h##r##h#######x#L##:p#####V#0p##V####0###r##h###P##,h#ď##h###`##########`######h###pп######h##V##!D#######h###p#########h### D#######h##r#-X#######q#####r###sStudentRecord=136
double=8, float=4, int=4, char=1



An example of how to use struct in C++ programming
algorithm


struct

FileIn.is_open

FileIn.getline
http://cplusplus.com/reference/iostream/fstream/

FileIn.close

strcpy

sscanf


console:
------------------------------------------------------
 1  Name:   Peter Pan           Age:  7 W: 23.8
 2  Name: Nine-tails Fox        Age: 999        W: 50.0
 3  Name:  Genius Babo  Age: 31 W: 80.8
 4  Name: Sleepless Turandot            Age: 21 W: 48.0
 5  Name: Choon-Hyang Sung      Age: 16 W: 42.0



'@GSMC > 서용덕: DMD Programming' 카테고리의 다른 글

week 4 review  (0) 2008.03.27
[Steve Ouallline] 6. Decision and Control Statements  (0) 2008.03.25
[Steve Oualline] 5. Arrays, Qualifiers, and Reading Numbers  (0) 2008.03.16
hw2  (0) 2008.03.15
week 2 review  (0) 2008.03.15
posted by maetel