|
Anyway there's a flaw, it should be:
int i = 10 + rand() % (21 - 10);
to generate a number ranging from 10 to 20 (including bounds).
In the above example you may also be correct (because you didn't mentionate of including both of the bounds), but in your original post, (19-0) is wrong, because rand() % (19-0) ranges from 0 to 18 (bounds included).
-- Carlo the Nitpick.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all
I am using a database application program using ODBC with MS Access as the database.
While navigating through the database,it is missing a particular row.
my code look like this
m_rs.Open( CRecordset::snapshot, _T( "SELECT * FROM DAUArinc717Frame2" ) );
m_rs.Move( Index );
for(i=0;i<128;i++)
{
data = (BYTE)strtoul( m_edit2, 0, 16 );
str.Format("%d",data);
m_rs.Edit();
m_rs.m_Data = str;
m_rs.Update();
m_rs.MoveNext();
b2 = strtoul( m_edit2, 0, 16 )>> 8;
str.Format("%d",b2);
m_rs.Edit();
m_rs.m_Data = str;
m_rs.Update();
m_rs.MoveNext();
}
I am updating to the database, the values read from the GUI.In this process when i==3,in that particular location in my database(row==264),it is skipping without updating and is moving to the next row.
Please help me..
Thanks in advance
Regards
Deepu
|
|
|
|
|
Deepu Antony wrote: In this process when i==3,in that particular location in my database(row==264),it is skipping without updating and is moving to the next row.
So does Update() throw an (CDBException ) exception?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks for the reply.
it is working now.I didn't changed anything.Sometimes it happens like that.
Don't know the exact reason
|
|
|
|
|
Hi!
I need help with this problem, I got this error before but I managed to solve.
But now I have a case with the virtual function.
The source looks like this(after the code I continued writing):
#include "stdafx.h"
#ifndef EMPTRANSH
#define EMPTRANSH
#include "Global.h"
#include "iostream"
#include "string"
using namespace std;
class EmpTrans
{
private:
int id;
char emp_name[MAXNAMELENGTH];
employee_status emp_st;
int salary;
salary_type sal_st;
char deal_date[DATELENGTH];
public:
EmpTrans();
static void Open();
static void Close();
void ReadNext();
virtual void Apply();
void UpdateId(int i){id = i;}
void UpdateSalary(int s){salary = s;}
void UpdateEmployeeStatus(employee_status es){emp_st = es;}
void UpdateSalaryType(salary_type ss){sal_st = ss;}
void UpdateDate(char * d){strcpy(deal_date,d);}
void UpdateEmployeeName(char en){emp_name[0] = en;}
int GetId(){return id;}
char * GetEmployeeName(){return emp_name;}
employee_status GetEmployeeStatus(){return emp_st;}
int GetSalary(){return salary;}
salary_type GetSalaryType(){return sal_st;}
char * GetDate(){return deal_date;}
};
#endif
class EmpTransAdd : public EmpTrans
{
public:
void Apply();
};
class EmpTransChange : public EmpTrans
{
public:
void Apply();
};
class EmpTransDelete : public EmpTrans
{
public:
void Apply();
};
When I compile and link this source I get the error,
when I remove the virtaul function from the Apply function, everything works fine.
What is the problem?
Do I need to take out the other classes from the source? or to include them inside the ifdef?
Thanks
|
|
|
|
|
You don't provide a body for the EmpTrans::Open(), EmpTrans::Close(), EmpTrans::Apply functions (well at least you didn't show us). You still need to provide a body for those functions in the base class, unless they are pure virtual functions (e.g. virtual void Apply() = 0; ), in which case it is mandatory that each child classes implement this function.
|
|
|
|
|
Will u pls show the code which creates the instance of ur class EmpTrans?
you have to provide the definition of Apply() in the base class. else it have to be a pure virtual function.
modified on Tuesday, March 24, 2009 6:44 AM
|
|
|
|
|
if you do not have implementation for virtual void Apply() in class EmpTrans, you should make it.
virtual void Apply()=0 A pure virtual function,
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
hi guys,
i am developing a worm scanner..
i have to choose the directories from Folder Browser Dialog..
when i does that i will get the directory C:\NVIDIA\Win2KXP
but i need to convert it to C:\\NVIDIA\\Win2KXP so that i can get the file names in the that directory using ListFiles......
since the symbol \ i could not put \ between "" and ''
how can i solve this ya??
help me plz...
|
|
|
|
|
Thilek wrote: but i need to convert it to C:\\NVIDIA\\Win2KXP so that i can get the file names in the that directory using ListFiles......
You don't need to convert it. You can use them straight. Only when you hard-code, you'll have to do this. Your question is slightly blurred to me though.
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
when i use C:\Private_Folder\forGetz its not seaching or getting the file name.. unless i use C:\\Private_Folder\\forGetz or C://Private_Folder//forGetz then its working
but when i use folder browser dialog , i will be getting as C:\Private_Folder\forGetz....
|
|
|
|
|
Are you using std::string to hold the value?
Maxwell Chen
|
|
|
|
|
|
Thilek wrote: when i use C:\Private_Folder\forGetz its not seaching or getting the file name.. unless i use C:\\Private_Folder\\forGetz or C://Private_Folder//forGetz then its working
Because those are string literals, which must contain double backslahes.
Thilek wrote: but when i use folder browser dialog , i will be getting as C:\Private_Folder\forGetz....
Which is correct.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You must understand the difference between the hardcoded "\\" and thr "\" in the value of the variable.
"\\": is an so calles 'escape sequence' FOR representing the "\" in the string. Look in the values of strings int the debugger
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
|
its so funny that i been breaking my head for days with this... thanks a lot.. u saved me...
|
|
|
|
|
I am trying to write a simple callback function for my own purpose, not to pass into Windows API as callback arguments. What I did below gets access violation. Where did I do wrong in the below code? Thanks.
typedef void (*fC)(int* p);
bool Test(int n, fC* p)
{
int* pN = new int;
*pN = 3;
(*p)(pN);
delete pN;
return true;
}
void fc(int* p)
{
*p;
}
void main()
{
Test(3, (fC*)&fc);
}
Maxwell Chen
|
|
|
|
|
change
bool Test(int n, fC* p)
to
bool Test(int n, fC p)
Also remove the cast.
void main()
{
Test(3, (fC*) &fc);
}
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Ooops! My bad ...
Maxwell Chen
|
|
|
|
|
|
Maxwell Chen wrote: bool Test(int n, fC* p)
Change to
bool Test(int n, fC p)
Maxwell Chen wrote: Test(3, (fC*)&fc);
Change to
Test(3, fc);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks!
Maxwell Chen
|
|
|
|