|
I already did that, but it still flickers the hell out of the screen.
But thanks for the reply.
|
|
|
|
|
How do I pass this structure i.e
struct s_test
{
char Name[15];
}test[10];
to a function??
Thanks,
grahamoj.
|
|
|
|
|
grahamoj, a structure is just a fancy variable, so you can pass it just as you would an int or a float or double. If it's really big, you'll probably want to pass it as a reference:
void foo (struct s_test * t); // the prototype
foo (&test); // the call
If you pass it as a value, you access the structure elements using the . operator; if you pass it as a reference use the -> operator.
Hope this helps!
'til next we type... HAVE FUN!! -- Jesse
|
|
|
|
|
Technicaly that is not a reference, that is a pointer. There is no such thing as passing by reference in C. You could call it a reference if you want to but no one else would know you where actualy talking about a pointer unless you specificaly mention the C language, and then they might figure it out.
// C Memory pointer
void foo(struct s_test* t)
{
int nSize = t->m_Size;
}
// C++ Reference
void foo(s_test& t) // or void foo(struct s_test& t)
{
int nSize = t.GetSize();
}
// C++ Memory pointer
void foo(s_test* t) // or void foo(struct s_test* t)
{
int nSize = t->m_Size;
}
Trust in the code Luke. Yea right!
|
|
|
|
|
Not to pick nits with you, but in the C 'bible' ("The C Programming Language", Kernighan & Ritchie) chapter 1.8 ("Arguments - Call by value") passing arguments by value is differentiated from other methods, which are referred to as "call by reference". Argument passing by value vs. by 'reference' is also mentioned several other places in the book. So, although this technique is implemented by passing pointers, it can be referred to in more than one way.
Still, your 'point' is well taken and your examples illustrate the issue quite nicely, much better than mine did.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
I see the confusion here...Passing by reference in C means to pass a pointer which means that the called function can modify it. Passing by value means you are passing a copy of the variable.
C++ introduced the concept of the reference type. A reference is like a pointer, but unlike a pointer is must be bound to a specific variable.
K&C have a very good explanation of pass by value/reference and pointers, however that was written before c++ came along. See Stroustrups book on C++ for an explanation of C++ references.
Reference types do not access their members with -> but with .
pass structure by reference in c:
main {
somestruct x;
function(&x)
}
function( somestruct* y) {
y->member = ...
}
same thing in C++
main {
somestruct x;
somrstruct& y = x;
function(y)
}
function(somestruct& ref) {
y.member = ...
}
|
|
|
|
|
Well, I cut my eye teeth on K&R... looks like I should curl up with Stroustrup's book soon.
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
By all means get Stroustrup's book. I just bought the third edition. The 3rd updates it according to the current standard, and adds a description of the standard libraries.
Software Zen: delete this;
|
|
|
|
|
I should have worded my replay earlier differently. I have not needed to read a book on C in years and I have know idea where my copy of "The C Programming Language" is. But here is the way I look at it (and yes I have been influenced by C++).
*pData is a dereferenced pointer (a dereference reference pointer to a memory address) and is therefore a reference to the data its self. In outher words pData could be considered an indirect reference to the data (although it looks like a direct reference to me).
Now then in C++ pData is a pointer to the data and *pData is a reference to the data. I beleive the first C++ compilers converted C++ code to C code and then use the already available C compiler (at least on UNIX).
Wether you agee with the above analiysis is only relevent to the acadimics of the subject though. Do mostly to my influence by C++, I perfer to differentiate between the two, since I do not wish to confuse outhers as to what I am actualy talking about.
Other than my comment, I did make a major mistake in the examples I gave the newbie. I forgot to give examples of how to call the function which sort of defeated the whole purpose.
foo(&myData); // C/C++ pass by address
// C++ pass by value or pass by reference depending
// on wether the function takes a value or refer a
// reference
for(myData);
Trust in the code Luke. Yea right!
|
|
|
|
|
Have you tried using a pointer?
void MyFunction(s_test* pTest)
{
..............
}
|
|
|
|
|
Here's my situation. I know nothing about database programming. I know lots about C++ and MFC and I use Visual C++ 6.0 but also have VS.NET 7.0. Someone has given me a machine with SQL Server and database on it. The database is not very big, maybe 1000 records. I want to get the database off the machine and I want to write an MFC application that will access the data and display it. I want to ship the application and I don't want people to have to have SQL or install anything extra to use the application. I'm sort of hoping that I can convert the database to some sort of file (maybe Access) and query it from MFC. The application would ship with the data and all reading and querying from the file would be local to the machine that the application is installed on.
How would people get started with this and does anyone have any ideas on how to proceed.
Thanks,
Brent
Brent Corkum
|
|
|
|
|
You can use an access database with ADO however this will require your users to have a recent version of MDAC http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28001860[^] which is several MB. Also I think the recent versions do not include JET which is the driver that you need. I switched to MSDE a few years ago because of this reason and for the more advanced SQL queries that are available with MSDE and SQL Server.
John
|
|
|
|
|
Can I write an Access database file fron SQL Server? What's the best way to read an Access database file and what are the requirements?
Thanks for the reply,
Brent
Brent Corkum
|
|
|
|
|
Brent Corkum wrote:
Can I write an Access database file fron SQL Server?
No. I believe you can use Microsoft Access to export the data however.
Brent Corkum wrote:
What's the best way to read an Access database file and what are the requirements?
Using ADO. But it requires that you have MSDAC installed as well as Microsoft Jet which handles the access file.
John
|
|
|
|
|
Actually, it's fairly siple. Launch the SQL Server Enterprise manager, drill down to the database table you want, right click it and choose Export. The ensuing wizard will allow you to select MS Access as the export format; after that you're done!
'til next we type...
HAVE FUN!! -- Jesse
|
|
|
|
|
Hi, trying to write out my "video conference" app now, able only to preview my video on my screen. Have not thought of a way to capture those to memory and subsequently send out via Windows socket to another PC connected in the network.
Trying using DIB functions from Video for Windows, but due to inexperience in programming, am not able to do so yet. Anyone can help by providing some ideas or samples?
Thanks lots.
extremalis
<extremalis@catcha.com>
|
|
|
|
|
if you want, you can take a look at the VNC from ORL, it is a program that allow to control a remote PC (as it does the PC Anywhere) but it is opensource and you could take ideas from there...
Hope this helps...
I don't remember now the link to the web page, but if you don't find it, I'll try to find it in my files...
|
|
|
|
|
http://www.iso.port.ac.uk/docs/downloaded/vnc/
Hi, I managed to find the programme on the above site after finding a search on it. Have not figured out whats going on yet, but i sure hope that it helps. Many thanks to you as well!!
Cheers
extremalis
<extremalis@catcha.com>
|
|
|
|
|
Take a look on avphone home:
http://www.banasoft.net/AVPhone.htm
|
|
|
|
|
There are numerous examples on how to download a file ising these classes, but there are none using the same classes to upload a file. Can it be done with these classes? What is involved?
Thank you.
|
|
|
|
|
Hi,
Is it possible to call explicitly a class from a DLL (not a simple C function but a C++ class)?
I suppose we must use ::Loadlibrary("my_dll_path_to_call") and GetProcAddress(hInstance, "class_name_from_dll") ... like the call of a simple C function!
Thanks for your suggestion.
Hello World!!!
from Raphaël
|
|
|
|
|
Even if this was possible, what would you do with the result of GetProcAddress(hInstance, "class_name_from_dll") ? Think it over, a class is not an entity per se in a program, only their instance objects (The situation differs in Java and C#, where classes are program entities).
GetProcAddress will give you pointers to functions, with a little work it is possible to make it return pointers to the methods of a given class: if this is what's in your mind, you might consider exporting classes from a DLL (see the docs), but this is a whole different beast than you're asking for.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yeap... It's true... I had forgotten this... Thanks.
(I think that I will sleep early today )
Hello World!!!
from Raphaël
|
|
|
|
|
I've written an console app. Is there a way to make the window from not popping up. I want to hide the window because there is nothing for the user to see.
How can I get a handle that is useful for showwindow to use to hide the window?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Probably the easiest way to accomplish this is to write your program as a Win32 app (with WinMain ) and not do any UI at all. If you still need argc and argv , resort to the equivalent global variables __argc and __argv .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|