A program to create a text file
Due to the bad and fast teaching of my professor i am unable to catch up with him. And he just simply gives up work which carry lots of marks.
My problem is i cannot figure out how to do this program, and this one is real different from the one i used to do previously. The description of the program is below. "Write a program that creates a text file containing the printed ASCII values of the data from a binary file, Take in an input file name as the first (and only) argument on the command line using argc and argv in main(). This file must be opened as a binary file. If the filename is not found on the command line, display an error message and quit the program" Please help me finish this or i will be in a trouble loosing lots of marks. If some one wants more information about the requirement please let me know!! |
Sorry, but this forum does not support requests for completing homework assignments. If you have a particular problem with code that you have already written, and need help getting over it, please do let us know.
Now, as for your assignment, try to break it down into smaller sub-tasks. 1. Define your program to include a main() function; this function should accept two parameters: argc and argv. 2. Add code to check if a parameter has been passed to your program; argc contains the number of arguments that are passed to the program. The program name itself is always the first argument, thus at a minimum, argc will be equal to 1. For your assignment, you require that argc equal 2. The list of arguments that are passed to the program are accessible via argv. argv[0] is the program name, argv[1] is the next argument, etc. 3. At this point, you should have a program that compiles and is able to run. You should test it without supplying a command-line argument, and again by supplying one (ie. a filename). Post back to this forum when done with step 3 (please show code within CODE tags), and then we can proceed to discuss the other matters of your assignment. |
microsoft word?
|
nope its done in Microsoft Visual Studio
|
bigearsbilly can u make the program for me? i really don't know how to do this one!!
I recently joined the programming course (so i am a noob) and my professor is expecting us to know everything, and i must say this one a difficult and i need more time to learn how to do this. |
I think bigears was joking that Word.exe is a program that takes a 'binary' format (what isn't binary?) and can output ASCII.
See dwhitney67's post, if you can't manage that, you are on the wrong course. We won't do your work, we will only help you learn to do it yourself. |
Quote:
If you have a SPECIFIC problem, come back, post what you've done, and where you're stuck, and we'll all be happy to help you. |
Quote:
|
bro try something atleast write a wrong code then we will help you surely...
|
darkhorse92: pay attention to dwhitney67's post, those are the steps to get to half of the assignment, which *really* is a very simple, intro-to-C type task (no, I'm no guru nor "expert"). What have you come up with until now? You say it's different from the earlier program, but if that was done in C too, at least you know how to write the main() function, that's something.
|
Start by reading the man pages for open(), read(), write(), close(), and printf(). These are the principle standard C functions that you will require.
Code:
man 2 open --- rod. |
Quote:
The task is not difficult. Actually it is a very primitive exercise, so the course cannot possibly be very difficult, unless you take giant leaps, and lots of them. Therefore your professor cannot expect you to know everything (otherwise your professor would ask you to craft a program that could predict correct lottery numbers, or something); the problem is probably you, having always taken the easy way, not learning anything. Either that, or then you're taking courses meant for older students than you. Either way, you must simply do it yourself (and learn), step by step, through mistakes, or quit and for a second think about what you're doing. If you can't do anything else, write a hello world program (no, do not copy an example, but write it yourself). Then think about the arguments and ask for more help. But if you're on a "introduction to programming/C/something else" course and cannot do this, don't expect much...these courses are not passed by obtaining maximum number of "marks", but by learning, which then "automatically" earns you marks. It doesn't matter whether you use MS Visual Studio or Vi+gcc or something else. In fact, you could choose your programming language quite freely and still be able to complete the task. If you don't understand that, you have problems. |
All times are GMT -5. The time now is 08:18 AM. |