omnet++ - C++ clarification -
i doing c++ code in omnet++ simulator came across piece of code. can please explain hpw sequence working ?
char *st = "data.enc"; std::ofstream myfile; myfile.open(st,std::ios_base::app); //please provide explnation line printf("\n aes encryption:\n"); for(i=0;i<4*4;i++) { printf("%02x ",out[i]+l); myfile <<out[i]+l<<"\n"; } printf("%02x ",out[i]);//what out[i] ? myfile.close(); printf("\n\n");
std::ofstream myfile; myfile.open(st,std::ios_base::app); //please provide explnation line
opens file in append mode. means insertions appended end of file instead of overwriting it.
for(i=0;i<4*4;i++) { printf("%02x ",out[i]+l); myfile <<out[i]+l<<"\n"; }
takes 16 first elements in out and:
printf("%02x ",out[i]+l);
prints them in hexadecimal format if bytes. 0
means fill 0s until reaching desired length (2). x
means print in hexadecimal.
myfile <<out[i]+l<<"\n";
appends contents of out adding 1.
printf("%02x ",out[i]);//what out[i] ?
prints out[16] (this time without adding one) in 2 digit hexadecimal format.
myfile.close();
closes file.
printf("\n\n");
prints 2 blank lines.
Comments
Post a Comment