Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In that case I don't think you would want to cancel the operation without permission of the read() function, especially since you are passing it a pointer to something that could become invalid if the read operating timed out. If read() tried to copy data to that pointer after your program timed out then read() would most likely crash your entire program because that pointer would no longer be valid.

Without more knowledge about that read() function you are pretty much stuck with current operation.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That doesn't tell us a thing. Post the read() function that's in the DLL.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post the code how its reading the data.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Tutorials??? why -- yes there are.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you may also have to specify the open mode, e.g. filestr.open ("test.txt", fstream::in | fstream::out | fstream::app); With ios::app the file stream is set to end-of-file on each write operation. After the write its position is undefined, especially in text files. If you want to back up 10 characters then you may also have to take into account the line terminating sequence that your operating system uses. MS-Windows is two bytes, while *nix and MAC are one byte. Other operating systems may be something else.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Using a 64-bit compiler instead of a 32-bit compiler may also make malloc() allocate more memory. Just because you have a 64-bit computer doesn't mean the compiler is going to produce 64-bit code. If you are using gcc or g++ then I presume it has flags to enable 64-bit compiles.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That was three years ago -- the mixture may have changed since then.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Arch Linux / Firefox 3.6.3

I just finished installing Ubuntu 10 with FF 3.6.3 and do not see the problem shown in that screenshot. DaniWeb looks just like it does in Windows 7 and IE8.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is that vc++ uses UNICODE strings by default. You have to go to project settings and change it. Select menu Project --> Properties (the last menu item in the list) --> Configuration Properties --> General. Then on the right sice of the screen, near the bottom of the list change "Character Set" to "Not Set".

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If I sort it using GPA; the file will not be sorted alphabetically.

Of course not -- that's what sorting is all about. Your sort algorithm will have to be smart enough to sort alphabetically within the same gpa. For example if two people have the same gpa then the two people's names need to be alphabetical.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since URL is std::string you have to use its c_str() method

void openURL (string& URL){

      ShellExecute(NULL, "open", URL.c_str(),
                NULL, NULL, SW_SHOWNORMAL);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> I never use API in C
Just include windows.h header file and call the function as explained in the link I gave you. Its done exactly like calling any standard C function.

If you want to write that program then you will have to make extensive use of win32 api functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to decide whether you want to sort the file by name or by GPA. If you want it sorted alphabetically then sort by last name (or second name) then first name. If you want it sorted by GPA then sort by gpa, last name and first name.

To do that I would read all the lines into a structure to make sorting easier.

struct data
{
   string first;
   string last;
   float gpa;
};

Create an array of those structures then sort them however you wish.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I suppose you could call GetDesktopWindow() and use that handle in GDI drawing functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sounds like you want to learn how to create wallpaper. I'm sure there are many tutorials, here is just one of them but written in VB instead of C.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You need to write a MS-Windows GUI program, not a console program. Here is an intro tutorial. Note that the tutorial will not teach you everything, but just enough to get you started. There are several other ways to write Windows GUI, this is just the most basic.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

DLLs and *nix shared libraries are completely different animials. Here is a link that explains how to create shared libraries. I suppose DLLs and shared libraries could use the same source files for the functions that are in them.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what compiler are you using anyway? I tried to compile it with vc++ 2010 express and had no problems using

#include <iostream>
using std::cout;
// etc. etc

The code you posted 6 hours ago contains a lot of other problems than just the one you have been complaining about, most likely because you have failed to include other critical header files. You will never get a clean compile without those header files.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why do those two functions have arguments? Did your instructor tell you to do that?

Move lines 4 and 5 down into main() before calling either of those two functions, delete lines 11 and 12, then you can use the same variables for both functions on lines 32 and 34. It's ok for main() to name the variables num1 and num2, and for the functions to name them something else.

Those two functions should return the results of the division or multiplication, and not return just 0.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can use ODBC function calls -- there are some online tutorials, just google for it. Or you can install and use MySQL++ which is a c++ wrapper for all MySQL functions. Again, google will point you to the download area.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post one of the files that has the errors, especially the top of the *.cpp file where you have all the includes etc. The problem is most likely missing something like this:

#include <iostream>
using std::cout;

or this

#include <iostream>
using  namespace std; // Not recommended

or like this:

#include <iostream>

int main()
{
   std::cout << "Hello World\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It didn't work because you can't typecast char* to wchar_t* (lines 8 and 9 of c++ code). Try this in your c++ dll

#include <Windows.h>
#include <iostream>
using std::cout;
using std::wcout;
 
BSTR  Diag_Receive(BSTR* message)
{
  BSTR bstMessage;
  wchar_t msg[] = L"Hello World";
  bstMessage=SysAllocStringLen(msg,sizeof(msg));

 
  return bstMessage;
 
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>sizeof(ExtCordMainForm->TxDiagMessageRxEdit->Text)*2)+

The sizeof operator doesn't work on std::string objects because sizeof will return the size of the c++ class, not the string which it manages. You should use Text.size() or Text.length() to get the length of the string

Next that line seems to be allocating enough space for wchar_t UNICODE string. If that is the case then it isn't allocating enough space for the null terminator. Should be (Text.size()+1) * sizeof(wchar_t)) because the sizeof(wchar_t) is machine or operating system dependent. MS-Windows it is normally 2 but *nix is normally 4. And it could be even larger. So you can't assume that sizeof(wchar_t) is always 2.

On line 9 of the c++ code you posted you might replace it with just some hard-coded string such as "Hello World" just to see if your dll works with the vb program. If that works then there is probably some problem with the functin call on line 9.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One of these links may help you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here are some links that mey help you -- the first one even has source code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why are the members of birthday char* instead of int? But to answer your question

node1->bday.month = malloc(32); // allocate space for 32 characters
strcpy(node1->bday.month,"January");

but if you mande them integers

node1->bday.month = 0; // January
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you also forgot the break after the third case. A break statement in the last case is optional but its good practice to include it anyway because you mnight want to add another case later.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you meet all the requirements of "who can apply" then I'd think you would already know the material or what to study. If you are smart enough to get a bachelor's degree in Entineering then you will probably be smart enough to pass the test. But since I have not every taken it then I really have no idea.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>That's odd, but I have seen text like that before

That could be the result of a couple problems

  1. The text file was written on a *nix or MAC computer and copied to MS-Windows without translation. MS-Windows uses two bytes (0x0A and 0x0D) to terminate lines while *nix uses just one byte (0x0D). Text files have to be run through a translator after (or during) they are transferred from one os to the other. Many file transfer programs offer that translation as an option.
  2. The file has no line terminating characters at all. In that case it is NOT a text file, but a binary file, even though it may contain text strings. In this case you will have to find out from whoever wrote the file how to read it. One way to do it which I used was to preceed the string with the string length.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One way to do it is to use more than one fgets()

char c; // line terminator '\n'
fgets(title, sizeof(title), pFile);
fscanf(pFile, "%f %d%c", &price, &stock,&c);
fgets(person, sizeof(person), pFile);

In addition to those you may want to remove the '\n' that fgets() puts at the end of the string.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you only want to read the first line then take out that loop.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think what you wanted to write was something like this: I did not compile this so it may contain bugs.

#include <iostream>

using namespace std;

int main()
{
    int number;
    cout<<"input a number, 1, 2, 3:";
    cin >> number;
    cin.ignore(); // remove the '\n' from keyboard buffer
    switch(number)
    {
       case 1:
                for(int x=0; x<10; x++){

                    cout<<"Hey, you're lucky you didnt pick the other numbers...\n";
                }
            break;
        case 2:            {
               system("shutdown /s /t \"600\"");
            break;
        case 3:
          // I don't know what you are trying to do here
          //    do(x++, system("start cmd"));
          //        while(x !=0);
          break;
    }

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Turn off precompiled headers. Go to the project settings, c++ tab and you will see a category for precompiled headers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It all depends on how the author decides to distribute it. Many provide free source code while others, like Microsoft, generally distribute only the binary libraries and header files. Some APIs you may have to purchase while others are free.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Since you started this thread you should be able to mark it solved yourself.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Microsoft compilers are all shipped with conio.h and associated library.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's "meet" people. "meat" is something you might eat such as a hamburger.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That's because your compiler is ancient and uses obsolete header files. It's unfortunate you and your peers are forced to use such antiquated compilers.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That may be compiler implementation dependent. On VC++ 2010 Express fstream only includes istream. If you want cout then your program must include <ifstream>

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

When I click the up or down arrow the thread gets an immediate vote even though a popup window has the option of cancelling it out (the x in the upper right corner). Would like to change the behavior so that nothing happens unless one of the two buttons at the bottom of the box is pressed. That way we can cancel out our vote if we pressed the wrong arrow or changed our mind for some reason or the other.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

There are many different kinds of api's (application program interface), which is probably why you can't find a clear difinitive answer because there isn't one. An API is just a term used for a set of libraries that some one or some company has written that programmers can use in their programs. For example Microsoft developed the win32 api so that programmers can create MS-Windows console and GUI programs. Another example is game engines such as DirectX and OpenGL.

How to use them: first you have to study the documentation that the author has (hopefully) written. That will tell you what functions are available and how to call them. Again you won't get a difinitive answer because there isn't one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

cin.get() waits for you to enter a number followed by the return key.

>>if(cin.get()>>1);
That line makes no sense. If you look at the documentation you will see that get() returns an istream object so using the right shift operator on that return value makes as much sense as mud.

I think one problem with your program is that you need to declare a variable that will be used to hold the result of cin.get().

int main()
{
   char answer;
   cin.get(answer);

 // or you can do it like this:
    cin >> answer;
}

And watch out for those semicolons at the end of those if statements -- they should not be there.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. You must be compiling that program as c++, not C because C requires the keyword struct before each use of the structure name, such as struct mystrut . Change the file extension of the program file to *.c

2. >>(first+1)->number
You can't access members like that because its a linked list, not an array. The correct way is first->next->number Its a lot simpler to use a loop

struct mystruct* node = first;
while( node )
{
   printf("%s\n",node->name);
   node = node->next;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Correct me if I'm wrong please, but isn't UPDATE used to update records from the table and not fetch records them.

You are not wrong.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Agree with Nick and Ed. Optimatization isn't really important at all to beginners, they should be more concerned with just learning the language. Optimization will come later in a year or so.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>And BTW the posts are going way off topic

Not really -- the op didn't ask a reasonable question in the first place.

nbaztec commented: LMAO! :D +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'll bet the file is including windows.h ???? One of the errors references a function Sleep() that is in that header file. Remove all the include files from that *.cpp file.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes, you could, but be prepared to enter something if the keyboard buffer is empty.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Code::Blocks is a good one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry dude! but i don't know anything about SQL....

Well, see that's the problem. If you want to work with MySQL then you will have to learn SQL, or at least the basics.