Thread: Any Room For Improvement?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    13

    Any Room For Improvement?

    I've been studying C for sometime now and Ive started with the standard library's of course, but anyway im trying to make sure to keep my code organized and neat. Main question is I know when making computations for big projects its important to use functions so we can have easy access if you need to update it, but its not necessary in a small project right? Im trying to organize my code 100% so any comments are great! Thanks.

    Code:
    // Client.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include "Client.h" 
    
    int main()
    {
    
    	std::cout<<"What is your name?\n";
    	std::cin>>client.name;
    	std::cout<<"Your name is: "<<client.name<<"\n";
    	std::cout<<"How many records will we be computing today?"<<std::endl;
    	std::cin>>records.number;
    	for (int i = 1; i <= records.number; ++i) // function maybe? we may want to call this a 100 more times in the future so we want easy access to it.
    	{
    	std::cin>>records.localnumber;
    	records.value += records.localnumber; // lol I hope my logic is good here lawl. :|
    	std::cout<<"Client records processed: "<<records.value<<"\n";
    	}
    
    }
    Code:
    // Client.h
    
    #pragma once 
    
    struct ClientStats_t // data structure
    {
    	int number; //data members
    	int localnumber;
    	int value;
    	std::string name;
    } client, records; // data object
    
    //ClientStats_t client; //a second header was causeing a conflict make sure you only include the struct once. or you will confuse the compiler.
    Code:
    // stdafx.h
    
    #include <string>
    #include <iostream>
    #include <stdio.h>
    #include <tchar.h>
    #include "targetver.h"
    
    // TODO: reference additional headers your program requires here
    Last edited by Clinthill98; 03-31-2010 at 09:06 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Moving between areas
    By Aliaks in forum C++ Programming
    Replies: 100
    Last Post: 07-27-2009, 02:23 AM
  2. Got a project. No help, confused on how to do this.
    By DazedNconfused in forum C# Programming
    Replies: 5
    Last Post: 10-12-2008, 07:02 AM
  3. Handling movement in text-adventures.
    By suzakugaiden in forum Game Programming
    Replies: 31
    Last Post: 02-13-2005, 03:18 AM
  4. MUD Concept Question
    By mrpickle in forum Game Programming
    Replies: 3
    Last Post: 12-01-2003, 12:45 PM
  5. Pathfinding AI? (Not the A* Algorithim)
    By harryP in forum C++ Programming
    Replies: 22
    Last Post: 08-01-2003, 02:32 PM