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