|
What do you mean by "keyed files".
Trust in the code Luke. Yea right!
|
|
|
|
|
Hello, my name is Alexander, I need urgent help with how to write a C++ program to read the data from an Excel spreadsheet (exported in fixed length format or comma delimited) to an object of the CFile class. Then, how to write a program to look at the records in the CFile object. Please, HELP
Alexander
|
|
|
|
|
|
Gee, if you submit this as your assignment, you might get 4.31/5.0, say 86%. I'll have to remember this, the next time I'm interviewing a Devry grad.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"Microsoft hasn't ever enforced its patents. Apparently they keep them for defensive reasons only. Or, they could be waiting 'til they have a critical mass of patents, enforce them all at once and win the game of Risk that they're playing with the world." Chris Sells Feb 18, 2003.
|
|
|
|
|
Hey all.
Just wanted to ask if it is possible to make Visual Studio break whenever a given variable gets a specific value?
Thanks in advance.
-Rune Svendsen
|
|
|
|
|
One Word: "Softice"
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Just modify the breakpoint to be a conditional breakpoint.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"Microsoft hasn't ever enforced its patents. Apparently they keep them for defensive reasons only. Or, they could be waiting 'til they have a critical mass of patents, enforce them all at once and win the game of Risk that they're playing with the world." Chris Sells Feb 18, 2003.
|
|
|
|
|
Yes. Set your break-point. Then press the ALT-F9 key to open up the BreakPoints watch window. Select the DATA tab. You'll now have the ability to set an expression based on a value. If you click on the ADVANCE button on that data tab, you can get really fancy.
D.
|
|
|
|
|
Dear all,
I can't borrow a book even though the code does not have any error. When I try to display the book details along with the member's name (in case the member has borrowed the book), I can't display the member's name, but only the book details and a message: "no member has borrowed a book".
Though the code works fine when I have one book and one member, but now that I'm using an array of books and members it doesn't work.
The code that displays the book and the member's name when I have 1 book and 1 member is:
<code>
void Book::display(Member* borrower)
{
cout<<"Book title and author are: "<<this->bookDetails<<"."<<endl;
if (borrower)
cout<<"The member's name is: "<<borrower->get_Data()/*get_name()*/<<"."<<endl;
else
cout<<"No member has borrowed a book."<<endl;
}
</code>
<code>
char* get_Data(){return this->name;}
</code>
<pre>returns the member's full name, entered in the constructor
I have an associationlist that holds pointers to associations. Each association has two pointers, one to a book object and the other to the member object.
<br />
class AssociationList<br />
{<br />
public:<br />
AssociationList();<br />
<br />
<br />
Member* get_data(Book* book);<br />
<br />
<br />
Book* get_data(Member* member);<br />
<br />
<br />
bool link(Book* book,Member* member);<br />
<br />
<br />
bool unlink(Book* book,Member* member);<br />
private:<br />
Association<Book,Member>* association_list[LIST_SIZE];<br />
};<br />
The code that performs the linking between 1 book object and 1 member object is the following:
<br />
template<class Book,class Member><br />
bool AssociationList<Book,Member>::link(Book* book,Member* member)<br />
{<br />
bool searching=true;<br />
bool success=true;<br />
int index=0;<br />
int free_slot;<br />
<br />
while(searching)<br />
{<br />
if(this->association_list[index])<br />
if((this->association_list[index]->linked_book()==book ||<br />
(this->association_list[index]->linked_member()==member)))<br />
{<br />
searching=false;<br />
success=false;<br />
}<br />
else<br />
index++;<br />
else<br />
{<br />
free_slot=index;<br />
index++;<br />
}<br />
if(searching&&(index == LIST_SIZE))<br />
searching=false;<br />
}<br />
if (success)<br />
this->association_list[free_slot]=new Association(book,member);<br />
return success;<br />
}<br />
Code that is used in the link function
<br />
template<class Book,class Member><br />
class Association<br />
{<br />
public:<br />
Association(Book* book, Member* member);<br />
<br />
Book* linked_book(){return this->book;}<br />
<br />
Member* linked_member(){return this->member;}<br />
<br />
private:<br />
Book* book;<br />
Member* member;<br />
};<br />
and
<br />
template<class Book,class Member><br />
Association<Book,Member>::Association(Book* book, Member* member)<br />
{<br />
cout<<"Association constructor called\n";<br />
this->book=book;<br />
this->member=member;<br />
}<br />
What needs to be done so that each member to be able to borrow one book?
(10-members)
(10-books)
(1 member can only borrow one book at a time)
Regards,
grscot
|
|
|
|
|
Dear all, I'm still struggling to display the book and borrower's details together.
Could someone help me?
regards,
grscot
|
|
|
|
|
I developed a simple object swap template. I simply do a binary swap of the class/structure contents. Yet I know that the developers of the STL libraries do not implement swaps in this way. Their implementation will make copies (via a copy constructor) and then use an assignment operator - "operator=()". The reason I want to do swaps in this manner is because of the obvious efficiencies. For instance, if I wanted to swap two branches of two very large tree structures, the copy and assignment operations become prohibative.
My question is in what instances does the code below NOT work?
template <typename _Ty>
void ObjectSwap(_Ty &obj1, _Ty &obj2)
{
// Don't swap on the same object
if (&obj1 != &obj2)
{
char tmp[sizeof(_Ty)]; // create a memory buffer
size_t sz = sizeof(_Ty);
memcpy((void *) tmp, (const void *) &obj1, sz);
memcpy((void *) &obj1, (const void *) &obj2, sz);
memcpy((void *) &obj2, (const void *) tmp, sz);
}
}
Scott K
|
|
|
|
|
I could see this working but it could lead to unexpected results if there are other pointers that point to the same object.
I'm confused though: why not just swap the pointers to the objects instead of the objects themselves? If you want to swap two branches of a large tree structure, you simply swap the pointers that point to those branches.
|
|
|
|
|
If an object contains one or more pointers to other objects, a simple bit-wise copy may not be what you want. Copy constructors and assignment operators let you do a so-called deep copy that addresses this. For example, suppose you have the following class:
class Stuff {
Stuff();
~Stuff();
int number;
char *string;
};
Stuff::Stuff()
: number(0),
string(new char[10])
{
strcpy(string,"Stuff");
}
Stuff::~Stuff()
{
delete []string;
} A bit-wise copy of one Stuff object to another simply copies the pointer to the string member. If one of the objects is then deleted, the other object's string member now points to freed memory. With a deep copy, you can ensure that each instance of the Stuff object has its own copy of the string:
class Stuff {
Stuff();
Stuff(const Stuff &stuff);
~Stuff();
int number;
char *string;
};
Stuff::Stuff()
: number(0),
string(new char[10])
{
}
Stuff::Stuff(const Stuff &stuff)
: number(stuff.number),
string(new char[10])
{
strcpy(string,stuff.string);
}
Stuff::~Stuff()
{
delete []string;
}
Software Zen: delete this;
|
|
|
|
|
Thanks, but my question was about swaping the contents of two objects. You are talking about copying an object - very different things. Using your example here is how you would manually swap the contents of two objects:
<br />
class Stuff <br />
{ <br />
Stuff(); <br />
~Stuff();<br />
void swap(Stuff &rhs):
<br />
int number;<br />
char *string;<br />
};<br />
<br />
Stuff::Stuff() : <br />
number(0),<br />
string(new char[10])<br />
{<br />
strcpy(string,"Stuff");<br />
}<br />
<br />
Stuff::~Stuff()<br />
{<br />
delete []string;<br />
}<br />
<br />
void swap(Stuff &rhs)<br />
{<br />
int tmpNumber = number;<br />
number = rhs.number;<br />
rhs.number = tmpNumber;<br />
<br />
char *tmpString = string;<br />
string = rhs.string;<br />
rhs.string = tmpString;<br />
}<br />
This will work 100% of the time if the object can guarantee that it manages the allocation and destruction of the string memory.
The code will obviuosly fail if the user somehow was able to assign stack allocated memory to the string pointer. In that case the Stuff destructor would try to delete a reference to stack memory - very bad thing to do.
My question then boils down to why would not the following swap code not work?
<br />
void swap(Stuff &rhs)<br />
{<br />
char tmp[sizeof(*this)];<br />
memcpy((void *)tmp, (void *)this, sizeof(*this));<br />
memcpy((void *)this, (void *)&rhs, sizeof(*this));<br />
memcpy((void *)&rhs, (void *)tmp, sizeof(*this));<br />
}<br />
|
|
|
|
|
Really what you are asking is, "Why can't you just change the memory location of an object?"
The answer is that other objects may be referencing it. If you use memcpy, it is not possible for the affected pointers to be fixed, like they could if you used copy constructors and/or assignment operators.
A linked-linked is a good example. If you swap nodes using memcpy, the list would become corrupted. Doing it the slow and safe way gives the objects the chance to reinsert themselves into the list correctly.
|
|
|
|
|
I have some(not actually few) html files that contain forms.I have a task to accomplish in this.
The task is, i get a string (typed by user while filling the form) and need to do a database lookup (through ODBC) and apply some algorithm(right now it is a dll written in VC++) to convert the data to the required form. The data typed by the user should go through this stage before getting submitted to the server.
What I want now is, I am struggling to find the correct way of doing it. Can it be an ActiveX control in VC? Then I need to sign it before using. Can I create a ATL HTML Control? But can other part of html call the function of this control (as like ActiveX)? I need to learn more abt that 'window.external', i suppose.
And what else can I do?
Thanx in advance,
Mahesh
|
|
|
|
|
I would be inclined to write an ISAPI DLL. That assumes, of course, that you have access to the server to put such a file in place.
|
|
|
|
|
Thanx for ur interest, DavidCrow,
The ISAPI DLL will be running in Server. right? For every string, (every field of form) it has to goto server and get it done. (U may argue that I need database look-up and its not possible to have that in every client. But this application is for Intranet and i am planning for Oracle server and all the clients connecting through the ODBC) If u assume there is no databse look-up, what would u be inclined to do?
Once again, Thank u so much,
Mahesh
|
|
|
|
|
Mahesh Perumal wrote:
The ISAPI DLL will be running in Server. right?
An ISAPI filter is a DLL that runs on an ISAPI-enabled HTTP server to filter data traveling to and from the server. The filter registers for notification of events, such as logging on or URL mapping. When the selected events occur, the filter is called, and you can monitor and change the data (on its way from the server to the client or vice versa). ISAPI filters can be used to provide enhanced logging of HTTP requests (for example, to track who is logging on to your server), custom encryption, custom compression, or additional authentication methods.
|
|
|
|
|
Thanx DavidCrow,
I thought something like "http://myserver/isapilib.dll?str='fieldvalue'" to get the output string.
You say that, without changing anything in the html, I can write my isapi dll that will catch all the strings and convert when the form is submitted. right? It seems good in the way that it doesn't require me to change the htmls. I look more into this and get back to u with the progress.
Thank u so much,
Mahesh
|
|
|
|
|
PLEASE EXCUSE MY BAD SPELLING IF THERE IS ANY
I am using a MFC application that is dialog based and a staticaly linked library (if I dont make it statically linked and a sherd DLL insted wene I transfer it to another computer and try to run the exe it has an error saying it is missing mfc70d.dll)
I wont to use #include <fstream.h> so I can use the variable typs ifstream and ofstream as file pointers but if I include fstream the build log will give me the following error's
NJROTC error LNK2005: "void __cdecl operator delete(void *,int,char const *,int)" (??3@YAXPAXHPBDH@Z) already defined in nafxcwd.lib(afxmem.obj)
NJROTC error LNK2005: "void __cdecl operator delete(void *,int,char const *,int)" (??3@YAXPAXHPBDH@Z) already defined in nafxcwd.lib(afxmem.obj)
NJROTC fatal error LNK1169: one or more multiply defined symbols found
I know the include fstream will werk with a sherd DLL but I have to get it to werk with a statically linked librery
CAN ANYONE HELP ME PLEASE
|
|
|
|
|
This looks like a problem with the libraries linked in the wrong order.
You need to force them to be linked in the right order by entering them in the linker "ignore" field, then entering them in the correct order in the "object/library modules" field. I think you should have nafxcw.lib first.
jhaga
|
|
|
|
|
Check the the code creation type matches the libraries being used. ie. If you are using multithreaded debug DLL's then you code must generate this as well. In VC6 this Code Generation in the Project Setup from memory.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
I do not know if this will help.
When you transfer the program to another computer are you also installing the mfc70d.dll on that computer? If you are not, assuming it is not alread installed, then that explanes why you have to staticaly link the library. To use a non-staticaly linked .DLL libraray: You need to either create an istall program that not only installs your program but also installs the .dll. If you want to do a manual install then you will have to copy the mfc70d.dll into the System32 directory (if it does not already exist) before you run your program.
You may also need to install any other .DLL files that are not already on that other computer. The only thing I am not sure of is whether you will need to restart that other computer after installing the .DLL files.
I use InstallSheild to create installation programs, but I have not heard any thing bad about Wyse so either one should be very good for your purposes. There might even be a good shareware program out there that you can use.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hope that anyone can help me. I am new to socket() programming. I try to connect to a tcp server. However my program fails when its get to gethostbyaddr() function. It keeps returning "null". My questions are:
1) Is there a difference between AF_INET and PF_INET?
2) The gethostbyaddr() returns "null" because it can't not see the tcp server IP on the network for some reason ?(eventhough I can ping or telnet to tcp server)
Many thanks!
peter.
unsigned int addr;
struct hostent *hp;
SOCKET conn;
conn=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
addr=inet_addr("10.23.50.133");
hp=gethostbyaddr((char*)&addr,sizeof(addr),AF_INET);
|
|
|
|
|