473,666 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

while can't go to the 2nd record.

Wen
Hallo,
Can someone tell me why my while doenst read the second, third.... record?
(This's a part of my code.)
I've looked for it in the books and on internet, but juist don't see the
probleem.
TI@
Wen
int klantNr, access;
Client MutatieRec, MasterRec;
OpenBestand(acc ess);

LeesMutatie( MutatieRec, klantNr);
while( MutatieRec.klan tNr !=HV) //HV is defined as 99999
{
cout<<MutatieRe c.klantNr;
LeesMutatie( MutatieRec, klantNr);
}
cin.get();

--

Met vriendelijke groet,

Wen
Jul 22 '05 #1
16 1362
"Wen" <We************ @hccnet.nl> wrote...
Can someone tell me why my while doenst read the second, third.... record?
(This's a part of my code.)
I've looked for it in the books and on internet, but juist don't see the
probleem.
TI@
Wen
int klantNr, access;
Client MutatieRec, MasterRec;
OpenBestand(acc ess);

LeesMutatie( MutatieRec, klantNr);
while( MutatieRec.klan tNr !=HV) //HV is defined as 99999
{
cout<<MutatieRe c.klantNr;
LeesMutatie( MutatieRec, klantNr);
}
cin.get();


AFAICT, 'LeesMutatie' has not been defined in this program. Could it
be the source why it's not working? Post complete code, and not some
fragments that are impossible to validate.
Jul 22 '05 #2
Wen wrote:
Hallo,
Can someone tell me why my while doenst read the second, third.... record?
(This's a part of my code.)

Modify the code as show below. If it prints "Mutatie.klantN r is equal to
HV", then problem is not in the code fragment you provided.

// ---------------------------------------------------------
int*klantNr,*ac cess;
Client*MutatieR ec,*MasterRec;

if ( MutatieRec.klan tNr == HV ) {
cout << "Mutatie.klantN r is equal to HV" << endl ;
}

OpenBestand(acc ess);

if ( MutatieRec.klan tNr == HV ) {
cout << "Mutatie.klantN r is equal to HV" << endl ;
}
LeesMutatie(*Mu tatieRec,*klant Nr);
if ( MutatieRec.klan tNr == HV ) {
cout << "Mutatie.klantN r is equal to HV" << endl ;
}
while(*MutatieR ec.klantNr*!= HV)**//HV*is*defined*a s*99999
{
cout << MutatieRec.klan tNr;
LeesMutatie(*Mu tatieRec,*klant Nr);
}
cin.get();
// ---------------------------------------------------------

--
CrayzeeWulf
Jul 22 '05 #3
Wen
Well, I can't post all my code, it's really to much. But I'd select this
part, so that you can can see what's wrong with it.
Regards,
Wen

#include <iostream>
#include <ctime>
#include <string>
#include <cstring>
#include <fstream>

const int HV= 99999;

struct Client
{
int klantNr;
char soort[2];
char naam[26];
char adres[26];
char postcode[7];
char plaats[16];
int bankNr;
int giro;
char mutcode[2];
char tariefAfspr[2];
};

using namespace std;
void OpenBestand(int & access);
void LeesMutatie(Cli ent & MutatieRec, int & klantNr);

int main()
{
int klantNr, access;
Client MutatieRec, MasterRec;
OpenBestand(acc ess);

LeesMutatie( MutatieRec, klantNr);
while( MutatieRec.klan tNr !=HV)
{
cout<<MutatieRe c.klantNr;
LeesMutatie( MutatieRec, klantNr);
}
cin.get();
}

void LeesMutatie(Cli ent & MutatieRec, int & klantNr)
{
ifstream mutatie ("mutatie.csv") ;
char puntkomma = ';';

mutatie >> MutatieRec.klan tNr >> puntkomma;
mutatie.getline (MutatieRec.soo rt, 2, ';');
mutatie.getline (MutatieRec.naa m, 26, ';');
mutatie.getline (MutatieRec.adr es, 26, ';');
mutatie.getline (MutatieRec.pos tcode,7, ';');
mutatie.getline (MutatieRec.pla ats, 16, ';');
mutatie >> MutatieRec.bank Nr >> puntkomma;
mutatie >> MutatieRec.giro >> puntkomma;
mutatie.getline (MutatieRec.mut code, 2, ';');
mutatie.getline (MutatieRec.tar iefAfspr, 2, ';');
if (mutatie.eof())
MutatieRec.klan tNr = HV;
}

void OpenBestand(int & access)
{
ifstream constant, klant, mutatie;

constant.open(" constant.csv");
if(constant.fai l())
{
cerr << "Het constantenbesta nd kon niet worden geopend" << endl;
access = 0;
}

klant.open("kla nt.dat", ios::binary );
if(klant.fail() )
{
cerr << "Het klantenbestand kon niet worden geopend" << endl;
access = 0;
}

mutatie.open("m utatie.csv");
if(mutatie.fail ())
{
cerr << "Het mutatiebestand kon niet worden geopend" << endl;
access = 0;
}
}
"Victor Bazarov" <v.********@com Acast.net> schreef in bericht
news:5IoIb.7985 6$VB2.162883@at tbi_s51...
"Wen" <We************ @hccnet.nl> wrote...
Can someone tell me why my while doenst read the second, third.... record? (This's a part of my code.)
I've looked for it in the books and on internet, but juist don't see the
probleem.
TI@
Wen
int klantNr, access;
Client MutatieRec, MasterRec;
OpenBestand(acc ess);

LeesMutatie( MutatieRec, klantNr);
while( MutatieRec.klan tNr !=HV) //HV is defined as 99999
{
cout<<MutatieRe c.klantNr;
LeesMutatie( MutatieRec, klantNr);
}
cin.get();


AFAICT, 'LeesMutatie' has not been defined in this program. Could it
be the source why it's not working? Post complete code, and not some
fragments that are impossible to validate.

Jul 22 '05 #4
Wen
10001;A;Ahold;K ruidenierstraat 2;1234AA;Zaanda m;123456789;123 4567;M;X
10002;D;Albert Heijn;Industrie terrein
5;1111BN;Zaanda m;341259878;125 4444;V;Q
10003;E;Kruidva t;Holtenbroek 123;2300CB;Schi edam;331215171; 3459770;T;S
10004;F;Blokker ;Amstelveensweg 331;1111SH;Diem en;812355565;90 02352;M;H
10005;A;Houtman ;Rotterdamsvaar t 123;3800ET;Goud a;567568456;333 4444;V;P
10006;E;Visa;Ro dekruisweg 23;1156SH;Dieme n;80335658;7456 891;T;O
10007;B;Hema;Zi lverkruisweg 523;5056AA;Apel doorn;753356564 ;7456891;T;O
These are information form the "mutatie.cs v" file.

"Victor Bazarov" <v.********@com Acast.net> schreef in bericht
news:5IoIb.7985 6$VB2.162883@at tbi_s51...
"Wen" <We************ @hccnet.nl> wrote...
Can someone tell me why my while doenst read the second, third.... record? (This's a part of my code.)
I've looked for it in the books and on internet, but juist don't see the
probleem.
TI@
Wen
int klantNr, access;
Client MutatieRec, MasterRec;
OpenBestand(acc ess);

LeesMutatie( MutatieRec, klantNr);
while( MutatieRec.klan tNr !=HV) //HV is defined as 99999
{
cout<<MutatieRe c.klantNr;
LeesMutatie( MutatieRec, klantNr);
}
cin.get();


AFAICT, 'LeesMutatie' has not been defined in this program. Could it
be the source why it's not working? Post complete code, and not some
fragments that are impossible to validate.

Jul 22 '05 #5
Wen wrote:

void LeesMutatie(Cli ent & MutatieRec, int & klantNr)
{
ifstream mutatie ("mutatie.csv") ;
char puntkomma = ';';

This will open the file "mutatie.cs v" again and again every time
LessMutatie() is called. So you will only read the first record.

Later,
--
CrayzeeWulf
Jul 22 '05 #6
Wen
ok, so I'd put the ';' away. I'll try that.
Thank you.
Wen

"CrayzeeWul f" <cr*********@no spam.gnudom.org > schreef in bericht
news:M4******** ***********@twi ster.socal.rr.c om...
Wen wrote:

void LeesMutatie(Cli ent & MutatieRec, int & klantNr)
{
ifstream mutatie ("mutatie.csv") ;
char puntkomma = ';';

This will open the file "mutatie.cs v" again and again every time
LessMutatie() is called. So you will only read the first record.

Later,
--
CrayzeeWulf

Jul 22 '05 #7
Wen
I'd try this, but it doens't work neither.
Regards,
Wen

void LeesMutatie(Cli ent & MutatieRec, int& klantNr)
{
ifstream mutatie ("mutatie.csv") ;
char komma;

mutatie >> MutatieRec.klan tNr >> komma;
mutatie.getline (MutatieRec.soo rt, 2, komma);
mutatie.getline (MutatieRec.naa m, 26, komma);
mutatie.getline (MutatieRec.adr es, 26, komma);
mutatie.getline (MutatieRec.pos tcode,7, komma);
mutatie.getline (MutatieRec.pla ats, 16, komma);
mutatie >> MutatieRec.bank Nr >> komma
MutatieRec.giro >> komma;
mutatie.getline (MutatieRec.mut code, 2, komma);
mutatie.getline (MutatieRec.tar iefAfspr, 2, komma);
if (mutatie.eof())
MutatieRec.klan tNr = HV;
}
"CrayzeeWul f" <cr*********@no spam.gnudom.org > schreef in bericht
news:M4******** ***********@twi ster.socal.rr.c om... Wen wrote:

void LeesMutatie(Cli ent & MutatieRec, int & klantNr)
{
ifstream mutatie ("mutatie.csv") ;
char puntkomma = ';';

This will open the file "mutatie.cs v" again and again every time
LessMutatie() is called. So you will only read the first record.

Later,
--
CrayzeeWulf

Jul 22 '05 #8
Wen wrote:
I'd try this, but it doens't work neither.
Regards,
Wen

void LeesMutatie(Cli ent & MutatieRec, int& klantNr)
{
ifstream mutatie ("mutatie.csv") ;

Wen,

Its not the comma. The problem is that you are creating an ifstream instance
named "mutatie" every time you call LessMutatie(). Every the first line of
this function is executed, you create an ifstream instance and open the
file "mutatie.cs v". At this point, the rest of the function reads the file
from the very beginning.

In order to fix this, you will have to redesign your code to make sure that
you do not open the file on every call to LessMutatie(). For example, you
can try opening the file outside LessMutatie() and pass it a reference to
an ifstream instance:

// -------------------------------------------------------------------------
void LeesMutatie(ifs tream& input_stream, Client & MutatieRec, int &klantNr);

int main()
{
int klantNr, access;
Client MutatieRec, MasterRec;
OpenBestand(acc ess);
ifstream mutatie( "mutatie.cs v" ) ;

LeesMutatie( mutatie, MutatieRec, klantNr);
while( MutatieRec.klan tNr != HV )
{
cout << MutatieRec.klan tNr << ":" << MutatieRec.soor t << endl ;
LeesMutatie( mutatie, MutatieRec, klantNr);
}
cin.get();
}

void LeesMutatie(ifs tream& mutatie, Client & MutatieRec, int &klantNr)
{
char puntkomma = ';';
if ( ! mutatie ) {
std::cout << "mutatie kaput." << endl ;
exit(1) ;
}
mutatie >> MutatieRec.klan tNr >> puntkomma;
mutatie.getline (MutatieRec.soo rt, 2, ';');
mutatie.getline (MutatieRec.naa m, 26, ';');
mutatie.getline (MutatieRec.adr es, 26, ';');
mutatie.getline (MutatieRec.pos tcode,7, ';');
mutatie.getline (MutatieRec.pla ats, 16, ';');
mutatie >> MutatieRec.bank Nr >> puntkomma;
mutatie >> MutatieRec.giro >> puntkomma;
mutatie.getline (MutatieRec.mut code, 2, ';');
mutatie.getline (MutatieRec.tar iefAfspr, 2, ';');

if ( mutatie.eof() )
MutatieRec.klan tNr = HV;
}
// -------------------------------------------------------------------------

There are other problems with the original LessMutatie() besides the
reopening of "mutatie.cs v". But that is a separate issue that you will have
to figure out.

--
CrayzeeWulf
Jul 22 '05 #9
Wen wrote:
I'd try this, but it doens't work neither.
Regards,
Wen

void LeesMutatie(Cli ent & MutatieRec, int& klantNr)
{
ifstream mutatie ("mutatie.csv") ;

Wen,

Its not the comma. The problem is that you are creating an ifstream instance
named "mutatie" every time you call LessMutatie(). Every time the first line
of this function is executed, you create an ifstream instance and open the
file "mutatie.cs v". At this point, the rest of the function reads the file
from the very beginning.

In order to fix this, you will have to redesign your code to make sure that
you do not open the file on every call to LessMutatie(). For example, you
can try opening the file outside LessMutatie() and pass it a reference to
an ifstream instance:

// -------------------------------------------------------------------------
void LeesMutatie(ifs tream& input_stream, Client & MutatieRec, int &klantNr);

int main()
{
int klantNr, access;
Client MutatieRec, MasterRec;
OpenBestand(acc ess);
ifstream mutatie( "mutatie.cs v" ) ;

LeesMutatie( mutatie, MutatieRec, klantNr);
while( MutatieRec.klan tNr != HV )
{
cout << MutatieRec.klan tNr << ":" << MutatieRec.soor t << endl ;
LeesMutatie( mutatie, MutatieRec, klantNr);
}
cin.get();
}

void LeesMutatie(ifs tream& mutatie, Client & MutatieRec, int &klantNr)
{
char puntkomma = ';';
if ( ! mutatie ) {
std::cout << "mutatie kaput." << endl ;
exit(1) ;
}
mutatie >> MutatieRec.klan tNr >> puntkomma;
mutatie.getline (MutatieRec.soo rt, 2, ';');
mutatie.getline (MutatieRec.naa m, 26, ';');
mutatie.getline (MutatieRec.adr es, 26, ';');
mutatie.getline (MutatieRec.pos tcode,7, ';');
mutatie.getline (MutatieRec.pla ats, 16, ';');
mutatie >> MutatieRec.bank Nr >> puntkomma;
mutatie >> MutatieRec.giro >> puntkomma;
mutatie.getline (MutatieRec.mut code, 2, ';');
mutatie.getline (MutatieRec.tar iefAfspr, 2, ';');

if ( mutatie.eof() )
MutatieRec.klan tNr = HV;
}
// -------------------------------------------------------------------------

There are other problems with the original LessMutatie() besides the
reopening of "mutatie.cs v". But that is a separate issue that you will have
to figure out.

--
CrayzeeWulf
Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
3833
by: Diez B. Roggisch | last post by:
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body - regardless of the loop beeing entered or not. So where is an actual use case for that feature? I imagined that the else-clause would only be executed if the loop body
0
1763
by: lea | last post by:
I have two combobox, I let the user to select report criteria FROM xx TO xx. i have a button call btnPrint to select report criteria and print according to the criteria. I able to SELECT the record based on the report criteria but i dunno how to print it out with the use of crystal report,because for my knowledge, Crystal report is only can retrieve all Records in the Table with generated dataset.
2
1374
by: jaYPee | last post by:
i'm wondering how can i update the current record in datagrid while still editing the record. cause i have a checkbox in my datagrid and i want to save the record before changing the value of this checkbox to true to enforce referential integrity. i don't have problem changing the checkbox to true if the record/row in my datagrid is already save. the problem is that if it is the 1st time i add record to this datagrid and then update the...
3
1394
by: gmac63 | last post by:
To be brief, I have never encountered this where I make a database query: <?php $db = sqlite_open('tc.db'); $result = sqlite_query($db,"select dir,app,protocol,sport,dport,mark from iptmarkView"); $row = sqlite_fetch_array($result);
1
2709
by: tkhouk | last post by:
I'm using Access 2003... I'm date and time stamping a record (to fields in a table) whenever it is accessed in the form and then the control is then sent back to the lookup box. While on the form, the date and time stamp happens, the record isn't actually written back to the table until I access a different record, or until I close the form. My question... is there a macro command that will save the record back to the table immediately after...
7
2402
by: Problematic coder | last post by:
Dim objdr As Data.OracleClient.OracleDataReader = Nothing Dim objcnn As Data.OracleClient.OracleConnection = Nothing Dim objcom As Data.OracleClient.OracleCommand objcom = New Data.OracleClient.OracleCommand(BuildSQL("Notes", id), objcnn) objdr = objcom.ExecuteReader objdr.Read() If objdr.HasRows Then 'Everything OK so far While objdr.Read() 'Jumps straight to End If here 'do something, it never gets here
1
1431
by: srinivasarao yarru | last post by:
hi friends, i am getting one problem in my software can you plz try to currect that thing. In my project total 5 tables are there.from table 3 onwards i gave composite primarey key. table3's corresponding form is Form3 in this form first i entered 1st record and then click add record button then i am getting new form but previous entered record fields disablity also it is showing in the new form.but entry time there is no...
3
3459
by: mckbill | last post by:
Is there a way I can direct the cursor to a specific field (variable) in a form by typing the field name while in form view? I have a form with many fields, and it would be nice if there were some method, similar to FIND RECORD (e.g., CTL + F ), where a dialog box would pop up and let me enter the field name, and then jump the cursor to that location. I currently do my edits by locating a record to be changed by ID using CTL+F and...
0
2242
by: vigneshrao | last post by:
Hi, I have been working on a script that loops through multiple records and sends data (one record per call) to a WS. I am supposed to make a new call for each record before sending the data. The problem I have is the first record gets processed fine where as the second record always; reason being the EAI expects it to be a seperate call Though I am creating/reseting a new service everytime within the foreach loop the data seems to be...
0
8438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8779
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6187
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.