Click here to Skip to main content
15,905,414 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Importing DLL of C# application Pin
RNEELY30-Apr-04 3:17
RNEELY30-Apr-04 3:17 
GeneralRe: Importing DLL of C# application Pin
student66692-May-04 18:12
student66692-May-04 18:12 
Generalcalling function in mixed mode assembly from unmanaged app Pin
godzooky27-Apr-04 6:22
godzooky27-Apr-04 6:22 
GeneralProblem with HDCs Pin
Serge Lobko-Lobanovsky27-Apr-04 2:37
Serge Lobko-Lobanovsky27-Apr-04 2:37 
GeneralLinear Search Pin
buttons25-Apr-04 10:02
buttons25-Apr-04 10:02 
GeneralBuilding Managed C++ Web Services Pin
Antti Keskinen22-Apr-04 8:59
Antti Keskinen22-Apr-04 8:59 
GeneralRe: Building Managed C++ Web Services Pin
ian mariano25-Apr-04 14:11
ian mariano25-Apr-04 14:11 
GeneralC++ Files Pin
buttons22-Apr-04 3:44
buttons22-Apr-04 3:44 
I have been trying to get the search facility below to work but it throws an error because of the memory being allocated I think.
Please Please take a look at the code and see you can do anything...Much appreciated. Buttons

#include <iostream.h> //Pre Processor Directives
#include <fstream.h> //Libary for Input funcitons
#include <iomanip.h> //Input/Output manipulation libary

void main()
{
ofstream file("Database"); //Create a new file
file.open("Database");

char* name[9];
name[1]="HP4p";
name[2]="HP5L";
name[3]="HP6p";
name[4]="Cannon2A";
name[5]="Cannon3B";
name[6]="Epson2";
name[7]="Epson3";
name[8]="Epson4A";

float cost[9];
cost[1]=32.99;
cost[2]=24.99;
cost[3]=30.00;
cost[4]=23.45;
cost[5]=31.99;
cost[6]=25.00;
cost[7]=30.00;
cost[8]=27.99;

int quantity[9];
quantity[1]=100;
quantity[2]=50;
quantity[3]=75;
quantity[4]=30;
quantity[5]=80;
quantity[6]=10;
quantity[7]=25;
quantity[8]=30;

char name8[13]="Cartridge";
char cost8[11]="£00.00p";
char quantity8[12]="Quantity";

{
file<<name<<' '<<cost<<' '<<quantity;
}
file.close(); //close the file

int num=0,x;
char sought[15]; //Declare Variables

cout<<"Display all records press '1' "<<"Do a Search press '2' "<<" '0' to Quit "<<endl;
cin>>num;

while(!num==0)
{
if (num==1)
{
cout<<"Total Items in stock \n"<<endl<<endl;

ifstream file("Database",ios::in); //ios::in for input from the file
//while(!file.eof())
cout<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name8;
cout<<setw(10)<<setfill(' ')<<setiosflags(ios::right)<<cost8;
cout<<setw(12)<<setfill(' ')<<setiosflags(ios::right)<<quantity8<<endl;

for (int x = 1; x < 9; x++)
{
cout<<endl<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<cost[x];
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<quantity[x];
}
}

cout<<endl<<endl<<"Display all records press '1' ";
cout<<"Do a Search press '2' "<<" '0' to Quit "<<endl;
cin>>num;

if (num==2)
{
cout<<endl<<"To search by the printers make type in the name e.g HP4p: Type 'N' for no more"<<endl;
cin>>sought;

ifstream file("Database"); //open file for input FROM file
//file.seekg(0); //set file pointer to first character

while (strcmp(sought,"N")!=0)
{
strcpy(name[0],sought);

x=9;

while (strcmp(name[x],sought)!=0)
x--;

if (strcmp(name[x],sought)==0 && x>0)
{
cout<<endl<<setw(20)<<setfill(' ')<<setiosflags(ios::left)<<name;
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<cost;
cout<<setw(8)<<setfill(' ')<<setiosflags(ios::right)<<quantity<<endl;
}
else
{
cout<<"No such item in stock"<<endl<<endl;
}
}
file.close();

cout<<"Display all records press '1' ";
cout<<"Do a Search press '2' "<<" '0' to Quit"<<endl;
cin>>num;

}
}
}

GeneralRe: C++ Files Pin
mccoyn22-Apr-04 5:41
mccoyn22-Apr-04 5:41 
GeneralRe: C++ Files Pin
Phil Boyd22-Apr-04 6:25
Phil Boyd22-Apr-04 6:25 
GeneralRe: C++ Files Pin
Navin23-Apr-04 9:42
Navin23-Apr-04 9:42 
GeneralInheritance of String class Pin
ra_sasi21-Apr-04 10:45
ra_sasi21-Apr-04 10:45 
GeneralRe: Inheritance of String class Pin
Phil Boyd22-Apr-04 6:26
Phil Boyd22-Apr-04 6:26 
GeneralRe: Inheritance of String class Pin
ra_sasi23-Apr-04 6:58
ra_sasi23-Apr-04 6:58 
GeneralEmbed C# controls in MFC dialogs/views Pin
rkvs20-Apr-04 7:49
rkvs20-Apr-04 7:49 
GeneralFailed in calling Manged Method from Unmanged code Pin
sanjay.attri20-Apr-04 1:33
sanjay.attri20-Apr-04 1:33 
GeneralTry to make a Manged project in C++ 2003 Pin
Harry200419-Apr-04 16:06
Harry200419-Apr-04 16:06 
GeneralLNK2022 metadata inconsistent Pin
mattknowles719-Apr-04 13:15
mattknowles719-Apr-04 13:15 
GeneralSystem.MemoryException Pin
BlackDice19-Apr-04 4:44
BlackDice19-Apr-04 4:44 
GeneralScaling drawings Pin
AnsGe19-Apr-04 3:08
AnsGe19-Apr-04 3:08 
Generaltimer in C++ Pin
Karthik Ram16-Apr-04 21:27
Karthik Ram16-Apr-04 21:27 
GeneralRe: timer in C++ Pin
Michael Mac17-Apr-04 4:02
Michael Mac17-Apr-04 4:02 
GeneralRe: timer in C++ Pin
Karthik Ram17-Apr-04 6:44
Karthik Ram17-Apr-04 6:44 
GeneralRe: timer in C++ Pin
Michael Mac17-Apr-04 22:40
Michael Mac17-Apr-04 22:40 
GeneralRe: timer in C++ Pin
dev_chandok29-Apr-04 22:21
dev_chandok29-Apr-04 22:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.