Well, i have a structure, input and output functions, to get some data, now i would like to make the following:
-the user inputs a number (for which i need a dynamic memory reservation)
-and that number declares how many times the input should loop)
so for example the use puts in 4; it will run the input function 4 times he can tpye in stuff for 4 different companyes or w/e ... same with the output
What exactly is your problem? It seems to me that you already know what to do, why just don't do it?
Oh, and by the way. You should not use new and delete for this kind of stuff. Use the class "vector" instead. It is much safer and in general less error-prone!
I knew what to do, but i didnt know 100% how to code it, and when i tryed to loop it on my own, it printed out the same result for all, not as it was entered, but its solved now .)... and i had to use new and delete, the exercise requested it
But thanks for the info anyway
Ok, one more thing, how can i write to a .txt file?
i want to write the output of this to a .txt file:
Code:
for (int i=0; i < count; i++)
{
input(x[i]);
output(x[i]);
}
i checkedout the writing samples on cpp.com, but didnt get anyhting to work for me... there are only examples when you have just cout, but i have a function call...
Struct Allokieren ? 12/08/2012 - C/C++ - 11 Replies Hallo,
Ich arbeite mich gerade durch das Buch C++ A - Z und bin gerade bei den Structuren, so
jetzt habe ich mir als beispiel ein kleines (Telefon Buch) gemacht ganz simpel (Vorname, Nachname, Geschlecht, Nummer)
Code
#include "stdafx.h"
using namespace std;
struct and classes 08/03/2012 - CO2 Programming - 6 Replies took about 50 pages reading about difference between structs and classes , so i thought it's good idea to sum up this for whoever want to get it with a spoon , feel free to correct or add information
at struct cannot have instance field initializers in structs
struct time
{
private int x = 5; // compile-time error
}
Structs cannot contain explicit parameterless constructors
struct time
{
[c++] struct 08/25/2011 - C/C++ - 2 Replies Kann closed werden. sry
Packet Struct's 05/02/2009 - Kal Online - 30 Replies Mir war langweilig hier nen beispiel wie ihr wie ich finde alles bischen besser aussehn lassen könnt :P
struct PacketsSend
{
DWORD VersionCheck;
DWORD Login;
DWORD Ping;
DWORD Skill;
DWORD Chat;