Like Tree1Likes
  • 1 Post By rogster001

Programming in C++

This is a discussion on Programming in C++ within the C++ Programming forums, part of the General Programming Boards category; I have missed a few lectures due to sickness and I have an upcoming programming test. I've been going through ...

  1. #1
    Registered User
    Join Date
    Jan 2012
    Posts
    2

    Programming in C++

    I have missed a few lectures due to sickness and I have an upcoming programming test. I've been going through a few lecture notes and I have no idea on how to do the sample test.

    I'm fairly new to the course so the programming isn't advanced. I'd be grateful if anyone can help me on this. Any tips on where to start would be great.

    Edit:: Should have read around. I think I'll attempt to do it on my own and post back if a problem arises.

  2. #2
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    Edit:: Should have read around. I think I'll attempt to do it on my own and post back if a problem arises.
    good plan ;->

    A tip comes to mind for , i reckon , an easy mark or two, note your tutor's naming style on the functions requested and use it yourself.

    I dont actually think its the best as i prefer to capitalise each word in funtion name for C++ , but anyway take a look

    I assume the main learning points are focused on building a class, in which case it is a fairly basic task, the overall problem will be a little more difficult though because you will probably be expected to make nice tidy menu displays and screen control etc, unless you are using a GUI also, but for my money that is an aside to the main objective...

    speaking of main(), why o why is your tutor requesting this !!

    Main program file with function void main()
    Why is he teaching you this??? Sticking my neck out I will say I think there is some slight argument (as has been posted here before - Abalcher) for this when dealing with microprocessors, but for anything else...no no.
    Last edited by rogster001; 01-06-2012 at 01:59 PM.
    Elysia likes this.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,171
    The instructor is broken! Quick, get a hammer and fix it!
    FYI, SourceForge.net: Void main - cpwiki
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  4. #4
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    671
    I'm wondering why teachers keep coming up with this c**p. I think there is a hidden reason. I'm on the first semester (computer science) and in the first lecture this is what has appeared to my eyes:

    Code:
    void main()
    {
    }
    I am absent on all programming lectures since then..
    Last edited by kmdv; 01-07-2012 at 05:35 AM.
    I never put signature, but I decided to make an exception.

  5. #5
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    This tutor is UK university though, i cannot imagine he/she has explicitly stated use ' void main()' unless as a means to setup up a learning discussion later in the course, there is no way they could be ignorant, or 'against' the standard and have got the lecturer position in the first place.... I hope.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

  6. #6
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,641
    rogster001, you give University lecturers far too much credit. Someone needs to point out the standard to this "professor" so that his ignorance may be fought.

  7. #7
    Registered User
    Join Date
    Jan 2012
    Posts
    2
    Quote Originally Posted by rogster001 View Post
    This tutor is UK university though, i cannot imagine he/she has explicitly stated use ' void main()' unless as a means to setup up a learning discussion later in the course, there is no way they could be ignorant, or 'against' the standard and have got the lecturer position in the first place.... I hope.
    Someone in the class was moaning about how he tried to fix an error and just made it worse.

    Anyway I've done a simple menu system to move the wizard. Can anyone show me how to add a code so that when I move the wizard to the left, the co ordinates change?

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
    	int loop=1;
    	int choice;
    	string getinput;
    
    	while(loop==1)
    	{
    		system("CLS");
    		cout << ":Menu::\n\n"
    			 << "1. Question\n"
    			 << "2. Exit\n\n";
    		cin >> choice;
    		switch(choice)
    		{
    			case 1:
    				system("CLS");
    				cout << "::The Wizard is idle. \n\n"
    				     << "Which Direction would you liek to move?\n\n";
    				cin >> getinput;
    				if(getinput=="right")
    				{
    					system("CLS");
    					cout << "The Wizard has moved right";
    					system("PAUSE");
    
    				} if(getinput=="left")
    				{
    					system("CLS");
    					cout << "The Wizard has moved left";
    					system("PAUSE");
    				}
    			
    			case 2:
    				if(choice==2)
    				{
    					exit(0);
    				}
    		}
    	}
    }

  8. #8
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,403
    What coordintes? You havent coded any,all you are doing is getting input and outputting messages. and you havent coded the class or any of the functions in the execrcise either, maybe this is just a bit of scratch code while you work things out? I sent you a message with a bit of help stuff in a few days ago because you showed willing to give it go rather than some of the requests for 'homewok help' we get, check that out. And also you have not put any breaks in your switch. change your variable for the loop to a bool rather than an int, so then you can set it to true and just write while(loop), its moot, but better. Also experiment with the \r escape character in your menu displays, it might let you avoid one or two CLS calls... Which are not too portable, i know you are not expected to be writing multi platform or anything but lots of cls calls on anything lead to screen flicker and poor display.

    As for the tutor ask questions as it is a pretty poor show that somebody like that has a nice pay cheque for this rubbish when there are plenty of talented programmers with no work.
    Last edited by rogster001; 01-08-2012 at 03:34 PM.
    Thought for the day:
    "Are you sure your sanity chip is fully screwed in sir?" (Kryten)
    FLTK: "The most fun you can have with your clothes on."

    Stroustrup:
    "If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 12-11-2011, 03:25 PM
  2. Replies: 1
    Last Post: 08-19-2007, 03:55 AM
  3. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 10:48 PM
  4. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21