ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
Lots of folks here CAN write it for you. However, this is not OUR school work, it's yours. If you can't do it, tell the professor, and get help. Use your textbooks. YOU have to learn, not get handed the answer.
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.
Look, even if somebody made a program for you, you would still fail the course later, because this way you won't learn required material. Do a research, find few C/C++ tutorials, get a book about C/C++, read it, and start writing. It isn't that hard. You could also probably ask professor for help/advice (you know - catch him after lectures and ask), or ask more experienced student for help/tutoring. Instead you want people to do your homework for nothing.
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.
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.
So you were going to continue like that in the real life as well? "X can u [...] for me? i really don't know how to [...]" (supplement [...] with "breed" and you'll get it...)
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.