Getting back into the swing.

This is a discussion on Getting back into the swing. within the C++ Programming forums, part of the General Programming Boards category; Hey everyone, I've been away from computers and such for a while and I'm just getting back into the swing ...

  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964

    Getting back into the swing.

    Hey everyone, I've been away from computers and such for a while and I'm just getting back into the swing of things. I am on a computer with no administrator privileges, but fortunately I found a chrome app called sourceLair which allows me to compile and run simple console apps right in Chrome.

    Google win.

    Anyways, I'm not sure what to program, I need to re-familiarize myself with syntax.

    Any suggestions?
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  2. #2
    Password:
    Join Date
    Dec 2009
    Location
    NC
    Posts
    587
    Implement an algorithm, in the general form, like they do in <algorithm>, using templates and stuff. (If you don't remember any, implement bubble sort, it's easy). That should get you reacquainted with loops, iterators, containers (since you're writing the algorithm for a general container), and templates.
    Last edited by User Name:; 12-23-2011 at 08:07 PM.

  3. #3
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    I've decided to make an employee database, and slowly add functionality to it until it does neat stuff.

    This is what I've done so far haha.

    Code:
    // Experimentations.cpp : main project file.
    
    #include "stdafx.h"
    #include <iostream>
    #include <string>
    #include <vector>
    using namespace std;
    string input;
    
    struct employee
    {
    	string name;
    	string birthdate;
    	string startdate;
    	string enddate;
    	string payrate;
    };
    int main()
    {
        cout << "Welcome to the employee database." << endl;
    	getline(cin, input);
        return 0;
    }
    As you can see it doesn't do anything yet, I'm about to add functionality to be able to edit employee's contents.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  4. #4
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    Is there any way I can accomplish this without an error?

    Code:
    void edit(employee a)
    {
    	cout << "What would you like to change?" << endl 
    		 << "1. Name" << endl << "2. Payrate" << endl;
    	string input;
    	getline(cin, input);
    	if (input == 1)
    	{
    		getline(cin, a.name);
    	}
    	else if (input == 2)
    	{
    		getline(cin, a.payrate);
    	}
    	else
    	{
    		cout << "Please enter a valid selection, 1 or 2." << endl;
    	}
    }
    I can't find a good tutorial on the basic string on the website, at least not for what I'm attempting to do, is this even possible?
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  5. #5
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    I guess I could avoid the problem by using an integer as input, but i'd have to add more code for error checking and whatnot, and that doesn't seem good, one data type is easier to work with, right?
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

  6. #6
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    964
    Reading about stringstreams, don't give me the answer yet!

    By George I think I've got it!
    Code:
    void edit(employee a)
    {
    	string input;
    	int selection;
    	cout << "What would you like to change?" << endl 
    		 << "1. Name" << endl << "2. Payrate" << endl;
    
    	getline(cin, input);
    	stringstream(input) >> selection;
    	if (selection == 1)
    	{
    		getline(cin, a.name);
    	}
    	else if (selection == 2)
    	{
    		getline(cin, a.payrate);
    	}
    	else
    	{
    		cout << "Please enter a valid selection, 1 or 2." << endl;
    	}
    }
    Last edited by Shamino; 01-18-2012 at 06:32 PM.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Who designed Java swing metal look&feel
    By indigo0086 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-22-2008, 10:08 AM
  2. Basics help, getting back into the swing...
    By Shamino in forum C++ Programming
    Replies: 8
    Last Post: 05-17-2007, 12:27 AM
  3. java/swing gui
    By xddxogm3 in forum Tech Board
    Replies: 4
    Last Post: 07-12-2004, 06:46 PM
  4. What is Swing?
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 03-18-2002, 04:05 PM

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