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

moved

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

Please don't bump a three-year-old thread to ask a new question.

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

Shell programming in *nix is considerably more powerful than batch processing in MS-DOS and MS-Windows. Most things you see in *nix shell programs are not possible in batch files.

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

I'm confused -- do you want the threads in RealBasic (whatever that is) or in the DLL? The code I posted will create the threads in the DLL and will work regardless of the language that calls it.

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

>>this problem is solved..
Not with the code you posted it isn't solved.

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

line 16 and all other similar lines. replace the semicolon before endl with << cout << num1 << "is equal to" << num2 << endl;

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

Change the variable something to a more meaningful name.

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

Ok, so where's your code ?

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

you could just google for c++ algorithms to get a list of good books. And did you read the Read Me threads at the top of this C++ forum ? It has lots of book suggestions.

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

>>I'm confused with the syntax and its working

So am I. What operating system and compiler ? Graphics is os-dependent and sometimes compiler dependent, although there are os-independent 3d party libraries around.

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

>>i know its a lot, but i have the rest of my life to wait for answers ^^
Then the first place to ask all those questions is google. Some of those questions depends on the operating system and compiler. google first, then come back for answers to what you can not find.

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

See the Read Me threads at the top of this C++ forum. It contains lots of information about books etc. No point repeating all that information in this thread when it's already readilable available to everyone.

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

Q1: It worked for me using VC++ 2008 Express. I creaed a header file named myheader.h and put it in the same directory as all the other compiler's header files

#ifndef MYHEADER_H
#define MYHEADER_H

void foo(const char* p1, int i1);

#endif

Then I created a new *.cpp file. As soon as I typed foo( as shown below the IDE displayed the function and all its parameters.

#include <myheader.h>
#include <iostream>
using namespace std;

int main()
{
    foo(
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Q2) You place DLLs in one of the directories that are in your computer's PATH environment variable. If you don't know what that is then create a cmd.com command prompt and type PATH <Enter>.

I'll look some more at your Q1 and let you know later, unless someone else posts the answer before I get around to it.

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

what is your operating system ? *nix, MS-Windows, or something else ?

And what tutorial did you attempt to compile ? (link please).

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

moved

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

Welcome to DaniWeb where several of us old fogies live. If you forget where you posted something just click on your name at the very top of the page then click on the Find All Posts link.

Since you question is about MAC software I moved your post here to Tech Talk. I can't answer you question though because I don't know diddly about MACs.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
enum Day {Monday=0x01, Tuesday=0x02, Wednesday=0x03};
typedef struct  {
    int numberofDays;
    enum Day weekday;
} Week;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A DLL is a collection of code that is shared among several programs. Instead of duplicating that code in every program people put the code in a DLL so that every program can use it. The operating system running on your computer is a very good example -- the installation directory will contain many many DLLs

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

my question is in a java programming, how to programm a calculator in java.. please help me..

moved

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

Read some of these google links

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

Check spelling and capitalization -- line 11 of the header file (as posted above) is not the same as the class name.

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

My GUESS is that this is c++. If its some other language than let me know and I'll move it again.

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

You mean you want to write a program that injects a DLL into another already running program? As far as I know that can't be done because when the operating system loads a dll it adds the code in the dll to the address space of the program that uses it. Unless you write your own operating system that behavior won't be (easily) possible for you to duplicate.

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

1) In the first program snippet you read the input file as binary file then write the output file as if it were a text file. You can't do that because the buffer the end-of-line characters will not be interpreted correctly. Solution: open the output file as binary and use fwrite() to write out the data just as you used fread() to read it.

2) Use your compiler's debugger, set a breakpoint inside each of those functions, and find out what fopen() is returning. Is it returning a NULL pointer? Put another breakpoint on the line just after fclose(). When that one is hit, switch to Windows Exploror and check the file system to see if the output file was created and in the directory you thought it should be.

3) After creating the CFileDialog object and before calling its DoModal(), set its m_ofn.Flag to OFN_NOCHANGEDIR so that it don't change directories on you.

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

The #ifdef directive is a PRECOMPILER directive that comments out or uncomments out a block of code depending on some other condition. This is performed before the code is even compiled, so the actual compiler never sees the #ifdef directive. Nor is it affected at program executation time.

The condition must be satisfied before compile time, not during runtime. So what you are attempting to do on line 15 is just not possible because those variables are not known until runtime.

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

I don't know what GetHeath() returns, but you can't use it when reading the data file. What does that function return? And what are the parameters to SetHeath() ?

In the read function you will need to do something like this:

char something[255];
continueData >> playerName >> something >> x >> y >> m >> n >> g >> h >> Currentroom;
player.SetHeath(something);
Pikachumanson commented: Once agin you've helped me out of a jam! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but I don't how to use them
Of course you already know how to use header files because the code you posted used them, the ver first line in your program is using a header file. So all you do is create a file of your own and give it a *.h extension

//myheader.h
class Grades
{
   // your header file code goes here
};

You need to actually STUDY your text book to find out about c++ classes.

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

you can set up the mysql server on any computer you want to on the network. Then when you install the odbc driver on your computer you tell it which computer the mysql server is running on.

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

>>FIND1230
What will the server do if you want to find the 123d line in the text file? obviously that command syntax is lacking. Maybe you could put a comma between the line numbers
FIND1,2,50,123,0
Now the server can process a file that has an unlimited number of lines

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

this is a lot simpler

int main(int argc, char **argv)
{ 
    int sum = 0;
    int i;
    for(i = 1; i < argc; i++)
           sum += atoi(argv[i]);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

One link -- if you dare to read it.

techbound commented: The link was a good read. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Of course its possible, I've done it several times using ODBC device driver. There are several c++ ODBC classes to make that easier, some are free while others are not. Just google for ODBC c++ classes and you will find them.

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

Note: This isn't my code, but something I found in one of the WinAPI tutorials on a forum.

That's nice code for console programs. Doesn't help the OP though to clear a graphics screen as he has already stated (several times too)

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

>> So, how would you use/access a DLL that doesn't have a .lib paired with it?
Its called dynamic linking -- see links below. In c++ you would call win32 api function LoadLibrary() to load the dll into memory, then GetProcAddress() to get a function pointer to the function in the library that you want to access.

>>And what is a static library?
I already tried to explain that, but maybe I didn't do a very good job.
Definition of a static library.

Another link here.

EDIT: I think I found out what a static library is from Google, is this right:
A static library is linked to after you compile the project but before the executable actually runs. This creates a bigger file, but lets the program run faster than it would with dynamic linking.

Dynamic linking is when the compiler links to a .lib that corresponds to a DLL, and it looks up the function it needs during runtime, as they are called. This results in a smaller, but slower, program.

Is that right?

Yes, that is right. The speed difference, however, is very minal on modern lightning fast computers.

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

>>return &c;
That is returning a pointer to an object that was created on the stack. Your compiler correctly flagged it as a warning, but its is really an error. It is an error because variable [c]c[/b] is destroyed as soon as the function f() returns, and consequently the line in main() is receiving an invalid pointer.

The second example is ok because string literals are not put on the stack but reside in global space (the heap). You can safely return objects or pointers to objects that reside in the heap because they are unaffected when a function returns to its caller.

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

Really the only difference between them is that McCain is a Christian and Obama a Muslim pretending to be a Christian.

So, in your opinion all black men are muslems, and all muslems have to be hated because of 9/11 and the AQ. Why don't you admit it -- you are a racist.

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

First, you created the wrong kind of project. You created a win32 console application instead of an empty CLR project. After creating a new empty CLR project copy the *.cpp and *.h files into the project directory then add them to the IDE. After that the compiler will not give you a lot of grief over the use of the ref keyword.

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

look in the drawing functions in graphics.h. There is probably a function that will fill a rectangle with some desired color -- just make the size of that rectangle the size of the screen.

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

>>I see. So is there anytime when you would have .dll file, but no accompanying .lib file, or visa versa?

Yes. Some companies publish DLLs without accompanying *.lib. And *.libs have other uses than DLLs. When you create a static library a DLL is not produced.

Interesting... so C code can be interpreted by many different languages, but C++ code can't. Is that only when the code is compressed into a DLL? Like if I were to do the VB equivalent of #include (if such a thing exists) with a .h file using only C code, would it work?

you probably should read some of these links about mixed-language programming. It can get a little complicated.

>>So, what about the .lib files included with DirectX? Did they just happen to be compiled with VC++?
That is no coincidence. VC++ is a Microsoft product, as well as DirectX. I doubt you can use the same libs that were created for VC++ with other compilers. You might be able to get the same libs compiled with other compilers.

>>You create a C++ project in some compiler, and set it to compile as a .lib. You compile it. A .dll is created
No. You create a c++ project to compile as a DLL, and both the DLL and lib files will be created. The project type must be DLL, not lib. A lib project does not create a dll, but just creates a static library. They …

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

I just don't understand why many white people are so afraid of Obama -- So what that he is black (or half black) ? Does skin color make white men superior Presidents than blacks, or red, or yellow, or brown. Biggots would have the same problem if Obama were of Chinese descent, or Japanese, Korean, French, or you-name-it. Many white people are simply white-supremist-biggots (to put it nicely). They are scared to death, and will crap in their pants, when Obama, a black man, is elected to the most powerful and most elete position in the world. Obama could be the reincarnation of Jesus Christ and they would still do anything to keep him from getting elected. And the smear campaigns, such as Obama is a Marxist, Communist, Muslem, or terrorist presented in this thread as well as on the internet just proves my previous statements here.

There are many reasons that anyone can legatimately NOT vote for Obama this November. But race is not among them.

jephthah commented: but they'll paint him as a socialist so they can avoid being accused +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

So you want to find the smallest number in an array. First, create an int that will contain the smallest value and set its initial value to the first array element. Then loop through the remaining array elelments, test if the element is smaller than the counter. If it is smaller, then set the counter to equal the value of that array element.

Example:

int nums[5] = {5,4,3,2,1};
int counter = nums[0];
int i;
for(i = 1; i < 5; i++)
{
   if( counter > nums[i] )
        counter = nums[i];
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

DLLs are pre-compiled code. When you compile a dll (or get one from someone else that has been compiled for you) you will get two files: *.dll and *.lib. The *.dll is saved in a directory that is your PATH environment variable, such as c:\windows, and the code in the dll is run when your program is executed. The *.lib file is used by the compiler at link time to resolve all the symbols and function names that are in the dll. Your compiler used the *.lib every time it links your program -- normally every time you compile your program.

Header files -- the ones with *.h extension and most standard c++ headers without extensions -- are completly different than either dll or *.libs. Don't get all these files types confused because each file type has its own unique purpose. If you look in a header file all you will find is 1) #define's 2) function prototypes, 3) structure declarations, and 4) c++ classe declarations. You will normally NOT see any executable code.

>>are .libs language specific, like given any lib
Yes and no. DLLs compiled by C compiler (not c++) can generally be called from other languages. DLLs compiled by c++ can be called by other languages if the c++ functions meet certain criteria, such as no c++ classes or c++ specific code. The *.lib files generally can not be used with other languages -- they often can't even be used by other compilers.

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

A DLL is a library of functions that are shared among other executable programs. Just look in your windows/system32 directory and you will find dozens of them. When your program creates a DLL it also normally creates a lib file so that the application *.exe program can resolve symbols that are declared in the DLL.

A .lib is a library of functions that are statically linked to a program -- they are NOT shared by other programs. Each program that links with a *.lib file has all the code in that file. If you have two programs A.exe and B.exe that link with C.lib then each A and B will both contain the code in C.lib.

How you create DLLs and libs depend on the compiler you use. Each compiler does it differently.

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

There are a couple cross-platform libraries that I am aware of

1) GNU Common C++

2) DataReel

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

Yes, you can, but you can't use using namespace std; , i.e., And you can even do the using namespace std; stuff.

#include <string>

std::string str = "whatever";
class string {
public:
  std::string str;
};
string q;

I think :P

That won't work because the compiler will get confused about whether you want std::string or the string class you wrote. But you can do it if you declare your own namespace

#include <string>
using namespace std:

namespace MyNamespace
{
     class string
     {
     private:
         std::string mystring;
     public:
         string() {};
         void setString(std::string str) { mystring = str; }
     };
};



int main()
{
    MyNamespace::string mystring;

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

>>When I'm opening a file, is it the file that is text or binary or is it the stream that can be text or binary?

Both. You can open any file in either text or binary mode. When you open a binary file in text mode your program will probably just read a whole lot of junk because the stream will mis-interpret the bytes in the file.

If you have a file that was written with the stream opened in binary file, try to load the file in a text editor such as Notepad. What you will see is a lot of unreadable characters, a lot of spaces, and/or a bunch of graphic squares.

>>when I close a file is that when the stream object is destroyed?
No. Like any other object that was created on the stack it is destroyed when the function returns

void foo()
{
   fstream fin; // create an object

   ...
   ...
   // last line of the function will destroy the fstream object
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Oh I see -- that function is meant for MFC.

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

Read some of the suggestions in your other post

Thanks for pointing out that there were two threads about the same thing. I merged the two threads into one to avoid confusion and duplicate posting.