|
I would do something like:
bool* pBool = boolArray + 10; srand( (unsigned)time( NULL ) ); for (int i = 0; i < 10; ++i) {
memset(pBool, 1, sizeof(bool) * 12); int rIndex = rand() % 12; pBool[rIndex] = 0; do
{
int rIndex2 = rand() % 12; pBool[rIndex2] = 0; } while (rIndex2 == rIndex);
pBool += 12; }
I have not tested this so you need to try it a few times to make sure it produces the desired results.
|
|
|
|
|
Thanks a lot!!
Now it's working fine
Many thanks again!!
|
|
|
|
|
|
My program is showing "Declaration Terminated incorrectly".Please help........
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<string.h>
#include<ctype.h>
void stock();
void billing();
class SBILL
{ int slno;
int itemcode;
char name[50];
float quantity;
float price;
float ttlprice;
float taxrate;
float amt;
public:
void subenter()
{ cout<<"\nEnter the following details:"
<<"\n\tItemCode\t:\n\t\t";
cin>>itemcode;
cout<<"\n\tName\t:\n\t\t";
gets(name);
cout<<"\n\tQuantity\t:\n\t\t";
cin>>quantity;
cout<<"\n\tTax rate\t:\n\t\t";
cin>>taxrate;
subcalculate();
}
void subdisplay()
{ cout<<"\n"<<slno<<"\t\t"<<name
<<"\t\t"<<quantity<<"\t\t"
="" <<price<<"\t\t"<<ttlprice
="" <<"\t\t"<<taxrate
="" <<"\t\t"<<amt;
="" }
="" void="" subcalculate()
="" {="" ttlprice="quantity*price;
" amt="((taxrate*ttlprice)/100)+ttlprice;
" int="" getcode()
="" return="" itemcode;
="" }
}sb;
class="" bills
{="" billcode;
="" char="" cusname[50];
="" float="" billamt;
="" public:
="" sbill="" sub;
="" enter()
="" cout<<"\nenter="" the="" following="" details:"
="" <<"\n\tbill="" code\t:\n\t\t";
="" cin="">>itemcode;
cout<<"\n\tCustomer name\t:\n\t\t";
gets(cusname);
void dis1()
{ cout<<"\nBILL CODE\t:"<<billcode
<<"\nname\t:"<<cusname
="" <<"\nslno.\t\t"<<"name\t\t"
="" <<"qty\t\t"<<"price\t\t"
="" <<"ttl\t\t"<<"txrt\t\t"<<"amt";
="" }
="" void="" dis2()
="" {="" cout<<"\n\n\t\tbill="" amount="" :"<<billamt;
="" calculatebamt(int="" x)
="" int="" i;
="" billamt="0;
" for(i="0;i<x;i++)
" getcode()
="" return="" code;
="" }
};
class="" stock
{="" slno;
="" sitemcode;
="" char="" sitemname[50];
="" float="" squantity;
="" sprice;
="" staxrate;
="" public:
="" enter()
="" cout<<"\nenter="" the="" following="" details:"
="" <<"\n\titem="" code\t:\n\t\t";
="" cin="">>sitemcode;
cout<<"\n\tItem Name\t:\n\t\t";
gets(sitemname);
cout<<"\n\tQuantity\t:\n\t\t";
cin>>squantity;
cout<<"\n\tPrice\t:\n\t\t";
cin>>sprice;
cout<<"\n\tTax rate\t:\n\t\t";
cin>>staxrate;
}
void display()
{ cout<<"\n"<<sitemcode<<"\t\t"<<sitemname
<<"\t\t"<<squantity<<"\t\t"
="" <<sprice<<"\t\t"<<staxrate;
="" }
="" void="" dis1()
="" {="" cout<<"\nslno.\t\t"<<"\ncde\t:"
="" <<"name\t\t"<<"qty\t\t"<<"price\t\t"
="" <<"txrt\t\t";
="" int="" getcode()
="" return="" sitemcode;
="" }
};
void="" main()
{="" clrscr();
="" choice;
="" char="" ch[5];
="" do
="" cout<<"\nplease="" enter="" your="" choice"
="" <<"\n\t1="" -="" stock"
="" <<"\n\t2="" billing";
="" cin="">>choice;
switch(choice)
{ case 1:stock();
break;
case 2:billing();
break;
default:cout<<"\nSome error occurred in your choice. Sorry for the inconvenience.\nPLEASE TRY AGAIN!!!";
}
cout<<"\n\nWould you like to continue? (Yes/No)";
cin>>ch;
ch=toupper(ch);
}while(ch=="YES");
getch();
}
void stock()
{ int stockchoice;
char chs[5];
do
{ STOCK ST,STK[30];
cout<<"\nPlease choose your operation"
<<"\n1 - To add stock"
<<"\n2 - To update details of a particular item"
<<"\n3 - To delete details of an existing item"
<<"\n4 - To display details of a particular item"
<<"\n5 - To display the entire bill details";
cin>>stockchoice;
switch(stockchoice)
{ case 1: ofstream fout;
int n,i;
fout.open("STOCK.DAT",ios::app||ios::binary);
cout<<"\nEnter the number of items";
cin>>n;
for(i=0;i<n;i++)
{="" stk[i].enter();
="" fout.write((char*)&stk[i],sizeof(stk[i]));
="" }
="" fout.close();
="" break;
="" case="" 2:="" fstream="" fout;
="" fout.open("stock.dat",ios::app||ios::binary);
="" int="" cde,flag="0;
" cout<<"\nenter="" the="" code="" of="" item="" whose="" details="" you="" want="" to="" update:\n";
="" cin="">>cde;
while(!fout.eof())
{ fout.read((char*)&ST,sizeof(ST));
if(getcode()==cde)
{ ST.enter();
fout.write((char*)&ST,sizeof(ST));
}
else
flag=1;
}
if(flag==1)
cout<<"\nSorry such an item does not exist";
fout.close();
break;
case 3: int cde,flag=0,i=0;
char nm[50];
fstream fin;
ofstream fout;
fin.open("STOCK.DAT",ios::in||ios::binary);
fout.open("TEMP.DAT",ios::out||ios::binary);
cout<<"\nEnter the name of the item you want to delete\n";
cin>>nm;
while(!fin.eof())
{ fin.read((*char)&ST,sizeof(ST));
if(ST.getname()==nm)
{ ST.dis1();
ST.slno=1;
ST.display();
fin.write((char*)&ST,sizeof(ST));
}
else
{ flag=1;
fout.write((char*)&ST,sizeof(ST));
}
}
if(flag==1)
cout<<"\nSorry the record was not found.";
fin.close();
fout.close();
remove("STOCK.DAT");
rename("TEMP.DAT","STOCK.DAT");
break;
case 4: int i=0;
char nm[50];
ifstream fin;
fin.open("STOCK.DAT",ios::in||ios::binary);
cout<<"\nEnter the item name you want to display\n";
cin>>nm;
while(!fin.eof())
{ fin.read((char*)&ST,sizeof(ST));
if(ST.getname()==nm)
{ ST.dis1();
ST.slno=1;
ST.display();
}
else
flag=1;
}
if(flag==1)
cout<<"\nSorry such an item does not exist.";
fin.close();
break;
case 5: ifstream fin;
fin.open("STOCK.DAT",ios::in||ios::binary);
fin.read((char*)&ST,sizeof(ST));
STK[0].slno=1;
ST.dis();
while(!fin.eof())
{ fin.read((char*)&ST,sizeof(ST));
ST.display();
ST.slno=ST.slno+1;
}
fin.close();
break;
default: cout<<"\nSome error occurred in your choice. Sorry for the inconvenience.\nPLEASE TRY AGAIN!!!";
}
cout<<"\nWould you like to continue? (Yes/No)";
cin>>chs;
}while(chs=="YES");
}
void billing()
{ int billchoice;
char chb[5];
do
{ BILLS BI;
BI.SUBBILL SUB,SB[10];
cout<<"\nPlease choose your operation"
<<"\n1 - To bill"
<<"\n2 - To search for an existing bill"
<<"\n3 - To display a bill"
<<"\n4 - To display the entire bill details";
cin>>billchoice;
switch(billchoice)
{ case 1: ofstream fout;
fout.open("BILL.DAT",ios::app||ios::binary);
int n;
cout<<"\nEnter the number of items";
cin>>n;
for(int i=0;i<n;i++)
{="" bi.sb[i].subenter();
="" bi.calculatebamt(n);
="" fout.write((char*)&bi,sizeof(bi));
="" }
="" fout.close();
="" break;
="" case="" 2:="" int="" cde,flag="0,i=0;
" ifstream="" fin;
="" fin.open("bill.dat",ios::in||ios::binary);
="" cout<<"\nenter="" the="" bill="" code="" you="" want="" to="" search\n";
="" cin="">>cde;
while(!fin.eof())
{ fin.read((char*)&BI,sizeof(BI));
if(BI.SUB.getcode()==cde)
{ BI.dis();
BI.SB[0].slno=1;
BI.SB[i].subdisplay();
}
else
flag=1;
}
if(flag==1)
cout<<"\nSorry the record was not found.";
fin.close();
break;
case 3: int cde;
ifstream fin;
fin.open("BILL.DAT",ios::in||ios::binary);
cout<<"\nEnter the bill code you want to display\n";
cin>>cde;
while(!fin.eof())
{ fin.read((char*)&BI,sizeof(BI));
if(BI.SB.getcode()==cde)
{ BI.SB.dis();
BI.SUB[0].slno=1;
BI.SB.subdisplay();
}
else
flag=1;
}
if(flag==1)
cout<<"\nSorry such a bill does not exist.";
fin.close();
break;
case 4: int cde,i=0;
ifstream fin;
fin.open("BILL.DAT",ios::in||ios::binary);
fin.read((char*)&BI,sizeof(BI));
BI.SB[0].slno=0;
BI.dis();
while(!fin.eof())
{ fin.read((char*)&BI,sizeof(BI));
BI.SB.display();
BI.SB.slno=SB.slno+1;
}
fin.close();
break;
default:cout<<"\nSome error occurred in your choice. Sorry for the inconvenience.\nPLEASE TRY AGAIN!!!";
}
cout<<"\nWould you like to add another bill? (Yes/No)";
cin>>chb;
chb=toupper(chb);
} while(chb=="YES");
}
|
|
|
|
|
Did you really think that it's necessary to dump your entire unformatted code base here and expect us to guess where you are getting this error message?
[Edit]
You have several problems going on here. You have many for statements that are simply
for (i = 0; i>cde; a couple of which appear to have no purpose.
Your nested class declaration is incomplete.
Your include statements are missing.
You are declaring functions inside other functions.
This has nothing to do with C++/CLI
probably others.
[/Edit]
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
modified 27-Jul-15 16:45pm.
|
|
|
|
|
Well, thanks for bringing it to my notice.Actually when I copied it into the editor on the website, it looked fine, but after submission edges of the statements were cropped off so was the formatting
like the one u mentioned.I am not able to submit the complete statements.
|
|
|
|
|
You forgot the closing brace after function BILLS::enter() . If you formatted your code properly you would be able to spot such errors quite easily.
|
|
|
|
|
c++ code only
gym be performed by the system:
• Register members (data recorded for each member consists of membership ID, first name, surname, address, contact number and age)
• Update member details
• View member details
• Search for a member using membership ID as the key
|
|
|
|
|
|
We still don't provide code to order. You will have to either develop it yourself or resort to another site where you can hire developers. If you decide to develop it yourself and you encounter a specific problem, we'll probably be able to help. You've been told this before - please stop posting instructions.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
Did you ever ask your professor? This stinks to the high heavens as homework....
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
CREATE ONSCREEN HELP TO ASSIST THE USERS OF A COMPUTER PROGRAM.
|
|
|
|
|
Message Closed
modified 22-Jul-15 4:01am.
|
|
|
|
|
Despite the recent lounge discussion, I was tempted to flag your message. You may wish to reword or remove it.
|
|
|
|
|
It was a bit overboard, thanks for the gentle suggestion before hitting the nuke button.
Geek code v 3.12 {
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- r++>+++ y+++*
Weapons extension: ma- k++ F+2 X
}
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
|
|
|
|
|
DON'T SHOUT!
Typing everything in upper-case on the Internet is considered extremely rude.
This is now the second time you've posted exactly the same instruction - presumably from your homework assignment - in this forum. Whilst the unpaid volunteers who answer questions here will be happy to help if you encounter a specific problem with code you've written, nobody here is going to write your code for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
When i try to add a Dll file into the project ,using Add Reference-->under properties .The Dll file was created VC6.
The followwing error was shown Could not add reference: ..\..\\
for one of the reasons , -Targets a higher of the.net framework
-Not a.Net assembly, -Not a registered ActiveX control
suggest how to use the dll in the project
|
|
|
|
|
The error message is telling you the reason. The DLL created in VC6 is not a .NET assembly.
If you want to use it in your project, you will have to use P/Invoke.
EDIT:
Since this is the C++/CLI forum, I forgot to mention that you can also call the DLL functions directly from C++. But there is no way to add it as a .NET reference.
The difficult we do right away...
...the impossible takes slightly longer.
modified 19-Jul-15 14:16pm.
|
|
|
|
|
d. Create onscreen help to assist the users of a computer program
|
|
|
|
|
Did you mean to post this here?
If it's intended as a comment to an existing message, then use the "Reply" feature, not "New Message" - that way the conversation "flows" and the person you are replying to gets an email to let them know (just like you did to this comment)
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
With the new open source .Net implementation is there an open source implementation of C++\CLI?
|
|
|
|
|
Not sure exactly which part of .NET you're asking about but they are not open-sourcing the C++/CLI compiler.
|
|
|
|
|
I am pretty sure that it's just ASP.NET 5 that is going open source. I have not heard about anything else.
http://www.asp.net/open-source[^]
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|
|
|
You can lead a developer to CodeProject, but you can't make them think.
The Theory of Gravity was invented for the sole purpose of distracting you from investigating the scientific fact that the Earth sucks.
|
|
|
|