|
You want the ASP.NET Web Service. It creates a skeleton web service for you which runs under IIS.
|
|
|
|
|
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;
}
}
}
|
|
|
|
|
I had to add #include <string.h> to get it to compile.
strcpy(name[0],sought);
That statement is probally where the problem is. name[0] is an unintialized pointer, so when you try to copy a null terminated string into it you will be accessing a random location in memory.
One solution is to initalize it to something.
name[0] = new char[15];
You will have to remember to release that memory before you are done.
delete [] name[0];
Another solution is to just assign that pointer to point directly to the sought string.
name[0] = sought;
This seems a little strange, but it is pretty effecient. Also, you have to worry about freeing it later.
The next problem I get is with this statement.
while (strcmp(name[x],sought)!=0)
The reason is that x is initialized to be 9, but the highest possible index for name array is 8. Rember, indexing starts at 0. So, change x=9; to x=8;
There are a couple other problems with that code, but this will at least get you past the memory problems.
|
|
|
|
|
The first problem that I see is you're not creating the char pointer for name[0]. The other pointers are initialized to the constant strings. My recommendation is get rid of the char* and use std::string. It has a comparison operation implemented for you. Also your code will be much cleaner.
Phil
|
|
|
|
|
Yes, the char* name[9] area is the problem. When you assign stuff to it, you need to allocate memory. One way, as another suggested, is to use std::string instead of char *. You can also make these arrays constants. E.g.,
const char* name[9] =
{
"Lexmark Z25",
"HP4p",
"HP5L",
"HP6p",
"Cannon2A",
"Cannon3B",
"Epson2",
"Epson3",
"Epson4A"
};
Note I added an item at the begining, this is beause if the array isn't 9 items, the compiler will complain. Arrays start at index 0, btw. (It also happens to be the printer I have. )
You can use this same trick with the other arrays, for consistency, but for the strings, at least, it saves you the hassle of having to allocate memory and stuff.
Sometimes I feel like I'm a USB printer in a parallel universe.
|
|
|
|
|
Hi guys,
I am new to using inheritance in C++ programming .I am trying to implement some of the missing methods in C++ string class using inheritance.Even thoughi have coded the methods i am not able to apply those on the string data type,.Can any of you help me out on this
Thanks
Sas
|
|
|
|
|
Ummm - what missing methods are you referring to? Are you talking about std::string, or MFC/ATL CString?
Phil
|
|
|
|
|
I am talking about methods like rightJustify,strip() etc.. and i want to implement them in the inherited class.I wanted toknow how the declaration & implemantation of header will be..btw, am talking about std::string
your help will be greatly appreciated!!
Thanks
Sas
|
|
|
|
|
Dear forum members,
I have controls (UserControl) designed in C#.
Can anyone tell me how I can embed them in MFC dialogs/views ?
Any sample code will be very helpful.
Thanks in advance.
|
|
|
|
|
Hi,
I am working on an unmanged user interface .I am using the services of a COM Executable that is also unmanaged.
BUt to get the handle of the Com executable ,I have to go through Managed DLL(i.e this is the requirement).
I am able to retrieve the handle successfully, but some methods are failing.
The HR error value in these is 0x80131531
MSDN says that this exception thrown by the marshaler when it encounters an argument of a variant type that
can not be marshaled to managed code
I am helpless about this error.
Can anybody suggest some way to rectify it?
Thanks in Advance!
Sanjay
|
|
|
|
|
Can someone help me? I have VS C++ 2003. Am try to make a manged project. But there is no Managed C++ Application in the project box. What do I need to do.
|
|
|
|
|
I have two projects, one unmanaged. The other is managed using stl lists of classes declared in the unmanaged project. When building the unmanaged project, anywhere the lists are used produces these linker errors.
MotionTimelineControl.obj : error LNK2022: metadata operation failed (80131187) : Inconsistent method declarations in duplicated types (types: tools.thoth.MotionEventController; methods: .ctor): (0x06000013).
MotionTimelineControl.obj : error LNK2022: metadata operation failed (80131187) : Inconsistent method declarations in duplicated types (types: tools.thoth.MotionEventController; methods: load): (0x06000017).
MotionTimelineControl.obj : error LNK2022: metadata operation failed (80131187) : Inconsistent method declarations in duplicated types (types: tools.thoth.MotionEventController; methods: getEventItr): (0x06000022).
MotionTimelineControl.obj : error LNK2022: metadata operation failed (80131188) : Inconsistent field declarations in duplicated types (types: tools.thoth.MotionEventController; fields: m_event): (0x04000011).
tools.thoth.MotionEventController, uses lists of classes from the unmanaged project, and MotionTimelineControl.obj is from a class that takes a MotionEventController as an argument to two methods.
The only solution i have found to get around the linker error is in the unmanaged project is to create a class that is not used (the constructor is private), with public stl lists with the classes used in the managed project. i.e. (MotionTimeLineEvent is a class declared in the unmanaged project.)
if the managed project uses
void doFunc(list<motiontimelineevent>::iterator iter);
then declaring a public variable in the unused class:
list<motiontimelineevent>::iterator m_iter;
would clear up any linker errors having to do with lists of MotionTimelineEvents.
if anyone has any clue on how to resolve the inconsistent metadata, please throw me a bone, i have tried most available solutions but, any suggestions would be greatly appreciated.
|
|
|
|
|
while I'm running my app, everything seems to be working fine. Once I exit the app I get the following messagebox:
INTERNAL ERROR<br />
<br />
Unhandled exception in Debugger::HandleIPCEvent<br />
<br />
Event id = 0x225<br />
<br />
Exception code = 0xc0000005,Eip = 0x7928c531<br />
<br />
ProcessID = 0x4a4(1188), Thread id = 0x384(900)
then I get a messagebox telling me the following:
An unhandled exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll
I recently deleted some controls and their message map entries for a dialog, and I wasn't getting this error before, does anyone know what this might be?
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Hai Friends,
In my project i have lot of drwaing in a MDI child form. The form has scrollable contents also.
I want to show miniature of the drwaing form in child control something like picturebox or some other containers.(show the full drawings)
Anyone have any idea??
Thanks in advance
Anish
|
|
|
|
|
I am using alarm() to time a process.
Is there something with which i can measure by milliseconds ?
The alarm() in C++ allows only seconds and not anything lesser than that.
I did try ftime() and time(),But i need something to timeout automatically.
I am using RH linux and g++ 3.2
Thanks
|
|
|
|
|
Try GetTickCount();
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
I am doing it on Linux with a gcc compiler 3.2
|
|
|
|
|
Ups, I didn't notice.
43 68 65 65 72 73 2c
4d 69 63 68 61 65 6c
|
|
|
|
|
try using signal()
u can do anythin with it
|
|
|
|
|
Hello folks!
I urgently need to go through a C++ source code for checking whether in an algebraic expression the brackets and braces () and {} are nested. I have been trying to write it for a while now, actually I tried two ways but thats too much loops one in another for my level. Thanks, you would save me!
|
|
|
|
|
Hi,
In my Opinion, stack would be the better choice when task is expression parsing.
Thanks
Jitendra
|
|
|
|
|
Hello programmers,
I having problems with a combo box. I populate the combo box with strings. I am trying to write a fucntion that displays a message box and prompts the user to select a item from the combo box when the current selection is empty.
|
|
|
|
|
If nothing is selected the SelectedIndex property is null so you can use that or you can set some default value of SelectedIndex so that something is always selected by default. At the end you can put an empty string and set SelectedIndex to it's index and test if combo->Text is empty.
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
I write one dll in Managed C++, I add reference to WebProject, all done but when I open webpage design it occur an error "failed to load design..." someone can help me how to repair it.
thanks
Nho'c Ti`
|
|
|
|
|
I would like to use Extended MAPI in my C# programm, read a String-Property from a Message.
For this purpos I write a managed/unmanaged C++ DLL.
I have an Object* from mail.MAPIOBJECT which should be of the type IUnknown according to Microsoft documentation.
I need an LPMAPIPROP for HrGetOneProp(LPMAPIPROP pmp, int ulPropTag, LPVOID lppPro) which can be (I'm not sure, but I found it on a webpage) a pointer to a IUnknown.
But what are the lines between?
I tried:
<br />
static String* GetStringProperty(Object* MAPIObject, int PropertyNumber) {<br />
String* Val; <br />
char* bufVal;<br />
IntPtr pUnk = Marshal::GetIUnknownForObject(MAPIObject);<br />
LPMAPIPROP pMsgMAPI = (LPMAPIPROP)pUnk.ToPointer();<br />
if (pMsgMAPI!=0) {<br />
int hRes = HrGetOneProp(pMsgMAPI, PropertyNumber, (LPBYTE*)&bufVal);<br />
if (bufVal != 0) {<br />
if (hRes == 0) {<br />
Val = Marshal::PtrToStringUni(bufVal);<br />
}<br />
MAPIFreeBuffer(bufVal);<br />
}<br />
}<br />
return Val;<br />
}<br />
pUnk gets a Value but pMsgMAPI/IUnknown says undefined.
Please help
Bernhard Mähr
Spam these adresses: SpamCatcher@CuteConnections.Com Delete@CuteConnections.Com Recycle@BillyX.com Muell@BillyX.com
|
|
|
|