The functions in the link I posted are C, not MFC.
>>I want to read the system time zones and display on the console
I don't think there is a way to do that using only win32 api functions because it has no such list.
The functions in the link I posted are C, not MFC.
>>I want to read the system time zones and display on the console
I don't think there is a way to do that using only win32 api functions because it has no such list.
all win32 api functions are C functions. You have to do it that way to start learning windows gui. As you advance in your studies you can start to write c++ class wrappers for many of the functions. There are also already written c++ classes but to understand how they work you still need to know the underlying win32 api functions.
sizeof(int*)
returns the size of a pointer, while sizeof(int)
returns the size of an integer -- the two are NOT the same. And the lines you quoted are not the same either. Example: assume nrows = 10, ncols = 5 and sizeof(int) = 4. The first equation is 10 * 5 * 4 = 10 * 20 = 200. The second equation assume sizeof(int*) = 4, then 10 * 4 = 40. Clearly the two equations do not result in the same value.
Another way to look at those two code snippets you posted: the first allocates memory for a two dimensional array of integers while the second allocates memory for a one dimensional array of pointers.
Basically, I need to program a class which will connect to a MSAccess database. I'm using Visual Studio 2005 and C#. I'm really at a loss for what to do. I've looked at online tutorials but they all seem like gobbledygook and I don't understand ANYTHING about them!
Post link to the tutorials you have seen. Maybe you are not yet ready to write such a class or program.
vmanes: your sleep function may pause the program for awhile but at what price? It will probably consume nearly 100% of the cpu time and not allow much time for other processes to work. That function is not very operating-sytesm friendly.
@Ancient Dragon...
i want to ask what does clock function return and in what format and with what units(milliseconds/microsec/sec)someone told me in this community that if u want the output in seconds divide the value of clock_t variable by CLOCKS_PER_SEC...and u will get the time in seconds..
On MS-Windows and I think *nix too the clock function returns milliseconds. The calculation you cite is correct.
I am also not able to understand this
clock()-t1> [B]25[/B]
That is checking if the time that has expired is 25 or more milliseconds then do something. You said you wanted to print a character every 25 milliseconds, so that's the reason for the 25 in that conditional statement.
do it the same way as you would with cout to print to the console fout << "Hello World\n";
. The syntax is identical to cout. Then close the file fout.close();
before calling your showFile() function so that everything gets physically written to the disk.
..@experts..
plz check is it correct or i m wrong about it..
You are wrong. system("pause");
does not pause the operating system, although I suppose someone could write an operating system in which it would pause it but it would be pretty stupid to do that.
IMO *nix sucks because it is soooo complex. I know a lot of people will disagree and that's ok too because we each have our own preferences. Some will even say MAC is the way to go.
>>You says that, according to my code I can't send message to the window
Read Very Carefully and Very sloooooooooooowly. I did not say that. Shall I repeat -- I did not say that. What I said was that the window will never receive any of the messages your console program sends it. Calling PostMessage() does not guarentee the receipient will receive the message. When you mail a letter at the post office the person to whom you sent the letter may or may not receive it. If the person lives some place that has no post office then your letter will be sent to the Post Office's dead letter office. Same with Windows messages.
If you will just read this win32 api tutorial you will probably understand more.
You have to add a line just before the end of main() to stop the program from closing. Most people call getch() or c++ cin.get(), which is just waiting for keyboard entry.
Did you create a DLL project when you got to the window that listed all the different project types? I did, then tried to compile what Dev-C++ generated and got an error that the linker can not find dllcrt0.o even though its in the lib directory. I'm trying to find the solution to this problem.
doesn't matter what compiler you use. If you want to write a DLL then you need to create all those files as shown in the tutorial.
To start the DLL project select menu File --> New --> Project then select the DLL icon.
>>where it rains on your desktop
Huh! You aren't supposed to set your notebook out in the rain :) I had to get a new video card about a year ago for similar reason -- the game I wanted to play didn't work very well because it was too slow. So bought a new one for about $250 USD (or so) and it works great now.
Dev-C++ and Microsoft VC++ 6.0 (rarly any more) and VC++ 2005 Express.
I can send messages to the window. Send a message to close the window, (WM_CLOSE) and try to destroy the window. But not work. I can send messages to it.
You can send all the messages you want, but without a message pump to pass them along to the correct window they will just be tossed into the bit bucket by the Windows operating system. You need to read and code a tutorial about how to write a windows program.
It means -- do not ask us to write your programs that your teacher/instructor assigned to you. You won't learn anything if I write it so I will not. But we are more than willing to help YOU write the program yourself. But remember, we are all volunteers and none of us (except the owner of this web site) gets paid for our time.
You created the wrong kind of project. To create a console project, select menu File --> New --> Project --> then select the Console Application icon.
>>Used the console window as the main window because my application also console based application.
CreateWindowsEx REQUIRES a win32 api program because it is a GUI. You can't create one with a console program. Period.
>>He use API i tought that is for windows application.And must have WinProc.
I agree. Which is why his program crashes. And he doesn't have a message pump so the window will never get any messages even if it were created.
nevermind. I misunderstood the previous post.
you need to define them within the header file
template <class Type>
class openadd {
protected:
virtual int HashFunkcija(const long& item) const = 0;
Type **Element;
int TableSize;
Type DefaultItem;
public:
openadd(int TableSize=100);
openadd(Type DefaultItem, int TableSize = 100);
~openadd();
bool Store(const Type& item)
{
int index = HashFunkcija(item.GetPhone());
for(int probe =0; probe<TableSize; probe++)
{
if( Element[index]->GetPhone() == item.GetPhone() )
return false;
else if( Element[index]->GetPhone() == DefaultItem.GetPhone() )
{
Element[index] = new Type(item);//treba konstruktor kopije
cout << "Korisnik uspijesno ubacen!";
}
else
index = (index+1)%TableSize;
}
}
bool Retrieve(const long& tel, Type& found)const//ovdje je prvi arg int jer ce se trazenje vrsiti po broju
{
int index = HashFunkcija(tel);
for(int probe=0; probe<TableSize; probe++)
{
if(Element[index]->GetPhone() == tel )
{
found = *Element[index]; //dodjela objekata preko reference //skakljivo
return true;
}
else
index = (index+1)%TableSize;
}
}
};
Use the clock() function. Create a loop and display the next character in the string when the current value of clock minus the original value is >= 25
clock_t t1, t2;
t1 = clock();
while more characters to display
if clock() - t1 > 25
display a character
set t1 = clock()
end if
end loop
CreateWindowEx does not throw an exception on error so there is no point to the try/catch block. If the function fails then you have to call GetLastError() to find out the error number, and you can pass that to FormatMessage() to get a human-readable error message.
I don't think you want to use the console's window handle as the parent of a Windows GUI program. Instead, pass NULL as that parameter.
>>But I can't use WindowProc, because I use windows API here in my code
That's what the WindowProc function is for. Establish the WindowProc when you call RegisterClass before CreateWindowEx()
If you want to write win32 api programs then don't start out with a console program. Set this tutorial for the basics.
If you are in the MS-Windows environment include <windows.h>, call SetTimer() and write your timer event handler.
Example:
#include <windows.h>
#include <iostream>
using namespace std;
#pragma comment(lib,"User32.lib")
VOID CALLBACK TimerProc (HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
KillTimer(hwnd,uMsg);
cout << "timer event called\n";
}
int main()
{
HWND hWnd = 0;
hWnd = GetConsoleWindow();
UINT_PTR t = SetTimer(hWnd,100,200,TimerProc);
if(t == 0)
{
DWORD dwError = GetLastError();
char buf[255] = {0};
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
0,dwError,0,buf,sizeof(buf),0);
cout << buf << "\n";
}
cin.ignore();
return 0;
}
>>char *string2[100][4];
That is not the same as in the function prototypes. char * is a single one dimensional array, what you have created is a three-dimensional array. The two are not compatible. What I think you want is this: char string2[100][4];
which is a two-dimensional array, and the function prototype would look like this: void view(char string2[100][4], int * inv, fstream& hardware);
>>int *inv = 0;
That is a pointer that points to nowhere. Yet you are passing it to the functions and those functions are attempting to dereference address 0. That might well compile without complaint, but at runtime your program will crash and burn big time. What you are supposed to pass is a pointer to an integer.
int inv = 0;
...
view(string2, &inv, hardware);
Since my eyesight is too poor to see your monitor I am unable to help you any more that that. Post more code so that someone can see what you are doing.
>>What I'm wondering is that how come it matters which specific bit is turned on or off? And where would it be implemented in everyday use programs?
Its often used to pack booleans in one integer. Suppose you are working with several led lights attached to a serial port and you need your program to know if a specific light is on or off. One way would be to define a bool flag for each light. But a more efficient way would be to bitmap and integer. The program could use the '&' operator with a mask to check if the light is on or off.
I think I see what you're saying.
When viewing a thread, the page automatically wraps very long code lines that don't have any hard returns. On the new thread preview page, very long code tag lines stretch out the page.
Yes, that it :) But since you are working with new vBulletin it probably isn't worth the effort to fix just now.
I'm sorry but your problem is somewhat more complicated than I have time to work on this evening or tomorrow. Hope someone else can help you out now.
>>edit(string2[100][4], (int*) inv, fstream* hardware);
That line is wrong -- don't put the data types in that line, they only go in the function prototypes and function header, should be this: edit(string2, inv, hardware);
. You need to correct the line that calls view too.
Also don't confuse the address operator '&' and the reference operator '&'. The reference operator is used in function prototypes and function declarations to tell the compiler that the parameter is a c++ reference to some object. The address operator is used when calling a function to create a pointer to the object. The two are similar but not the same thing.
I'm incredibly confused?
Edit my original post then when in edit mode press the Preview button and you will see what I mean. You can also see the problem when you press Replay w/Quote then Preview
Also the title of this thread is inaccurate -- the presence or abselce of spaces has nothing to do with it.
>> do not know how to set global lo
delete lo from line 18 and declare it on line 8. Leave hwnd where it is on line 18.
Not sure what you mean. Do you want to create a function that is called by the operating system every few seconds ? That would depend on the operating system. I know its possible in MS-Windows programs but I don't know about other operating systems such as *nix.
If that is not what you want then you might explain in more detail or post some psudocode, such as this.
get start time
do something
get stop time
show difference between start and stop times
>>PostMessage(hwnd,WM_CLOSE,0,0);
You may be attempting to close the wrong window. Try making lo global and using that instead of the hwnd that is pass to WindowProcedure(). Not sure if that will fix the problem but its worth a try.
The file is gone!!!
Im getting a 404 error :(
I get the same thing. :'(
You can pass it as a parameter to the functions that need it. And pass it by reference, not by value void edit(char *string2[100][4], int * inv, fstream& hardware)
Well, when I Preview the above it doesn't work, but I see that it worked in the above post. It also didn't work in the original post on the c++ board because that's where I first saw it.
I discovered this just a few minutes ago that if a very long text with no spaces is gets cut
off. Does this in all tags, code, quote, and untagged. The only way to make it work right
is to manually put a C/R at some place. I would have expected it to be auto word wrapped
or auto wrapped when the width of the display area is reached.
no tags:
c:\documents and settings\jayson\my documents\visual studio 2008\projects\solution 3\assignment 3\hardware.cpp(113) : error C2228: left of '.seekg' must have class/struct/union type is ''unknown-type''
code tags:
c:\documents and settings\jayson\my documents\visual studio 2008\projects\solution 3\assignment 3\hardware.cpp(113) : error C2228: left of '.seekg' must have class/struct/union type is ''unknown-type''
quote tags:
c:\documents and settings\jayson\my documents\visual studio 2008\projects\solution 3\assignment 3\hardware.cpp(113) : error C2228: left of '.seekg' must have class/struct/union type is ''unknown-type''
>>'hardware' : undeclared identifier
where did no define hardware ? You can ignore that second error message because it is related to the first one.
>>Is there a better way to do this?
Fix the error?
>>Boost.Format maybe?
Yes, that's a good alternative, but unfortunately that isn't standard c++ (yet) either. I have never used boost but I have heard many of their classes will be in the next version of c++ in one for or another.
>>What is Diskless PC?
It is a PC without a hard drive -- boots up from a network drive.
Is the weighing device attached directly to the diskless PC via serial or parallel port? If yes, then why don't you just simply call printf() to display the information on the screen ? I think you are making it much more complicated than it needs to be.
But I though DMA is for integers contain in an array only? Characters won't work for DMA....I've tried it before
Now that I know what you mean by DMA -- it works with any data types, either simple or complex. If you couldn't make it work then its your fault not that of the language.
Thanks, it works now :)
Below is for readers who may not realize what the solution was.
#include <stdio.h>
int compare(const void *a, const void *b)
{
const char* a1 = *(const char**)a;
const char* b1 = *(const char**)b;
return strcmp(a1,b1);
}
int main()
{
int c = 0;
char* _array[] = {"now ","is ","the ","time","for ","all ","good"};
c = sizeof(_array)/sizeof(_array[0]);
qsort(_array,c, sizeof(char*),compare);
cout << "\n\nThe alphabetized words are:\n";
for (int i = 0; i < c; i++)
{
cout << _array [i] << "\n";
}
cin.get();
}