InterviewSolution
| 1. |
Solve : File conversion to .txt file? |
|
Answer» Hi there everyone! why not use a hex editor?++1 Ok, maybe the "problem" is my 1997-Qbasic way of thinking... So, what you all are telling me is that I can read every byte from a file (any file) and then encrypt it (that's the purpose of my project)... And I don't need to "convert" to .TXT, as I did in 1997 with my Qbasic program... Now I'm starting learning C and the final/update/real question (spoiler!) is: which is the C command (or the code) to read any single byte from a file to use it as a variable? And how can I do the reverse?I'm still at a loss as to WHY ? you seem intent on re-inventing the wheel. if this is some sort of logic problem or coding test, OK then, but there are already programs out there that will do what you want, that is, look at any sort of file at the binary (hex) level and if desired, also encrypt that file.Quote from: Mark. on January 14, 2018, 04:40:13 AM I'm still at a loss as to WHY ? Ok... why? Maybe I want to re-invent the wheel... The point is that I want to start again with programming and - as a sort of exercise - I want to make again that program that I create in 1997... There is no why... I'm not a professional, it's my hobby... So, as you were saying, it's like a coding test... Where do I start? I've just started learning C, so I'll arrive to the point, but I just wanted a "spoiler". So, now I know that what I want to do is possible (even if in a different way than I thought), but I'd like to know also how. P.S. What's "++1" above?Quote from: sal.ventre on January 14, 2018, 05:41:34 AM P.S. What's "++1" above?A compact way of saying "I AGREE with the above". You would be better looking at Stack Exchange or Rosetta Code. Code: [Select]which is the C command (or the code) to read any single byte from a file to use it as a variable? And how can I do the reverse? It's unclear from what context you are asking this question; even in QBASIC there was no "command" (or statement) that would read a single byte from a file to a variable or the reverse. It was a series of operations that you put together. There is loads of documentation for the C language and it's standard libraries. Generally SPEAKING, sticking to C, you'd open the file with fopen(), read from it with fread(), translate it to a hexadecimal character array using one of the formatted print functions(printf, fprintf, etc) and close the file using fclose().Quote from: BC_Programmer on January 14, 2018, 01:04:41 PM Code: [Select]which is the C command (or the code) to read any single byte from a file to use it as a variable? And how can I do the reverse? Ok, thank you... This is what I needed to know... I didn't know that this was possible even in Qbasic... I'm an autodidact, so I don't know the whole theory... |
|