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

>> pszFileText = LPSTR(GlobalAlloc(GPTR, dwFileSize + 1));

typecast is wrong: pszFileText = (LPSTR)GlobalAlloc(GPTR, dwFileSize + 1); Add this to the top of the *.rc file #include <winuser.h> You have to add comctl32.lib to the list of libraries. For your compiler it probably has *.a extension instead of *.lib.

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

const just says the function will not change anything

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

What computer language was used to create the program you are spawning ? I know some MFC programs return 0 back to the os regardless of what the programmer intended -- hopefully M$ has corrected that by now. If it was written in C or C++ that problem should not occur.

Write a short little program that does nothing more than create the process and get its exit code status to see if the problem is elsewhere in your larger application. Sometimes its easier to debug with much smaller programs.

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

line 6: its int main(). c++ does not allow default function return types.

lines 4 and 5. Move those down so that they are within main() and not global variables. Globals are bad and can normally be avoided.

line 10: Entering numeric data types such as integers leaves the '\n' <Enter> key in the keyboard buffer which causes problems. You have to flush it out, like this: cin.ignore(); Here is a more detailed explanation how to flush the input buffer.

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

After calling CreateProcess() call WaitForSingleObject(). When that returns then you can call GetExitCodeProcess()

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

how is d_player declared? If it an array of character strings then you may need this: if( name == d_player[i])

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

Sorry, I can't help you any more because I don't have a compiler that will compile MFC code. Post your problems on their forums.

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

We only help those who help themselves. Post the code you tried. You will have to know a little about pointers if you are required to pass variables by reference.

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

C programs do not need all those typcasts. Only C++ requires them.

Why are you using all those difficult-to-follow pointer arithmetic? It would be much simpler and clearer to just use normal array indices via [] operator.

ptrB= calloc(row,sizeof(int *));
		ptrC= calloc(row,sizeof(int *));

		for (counter1=0;counter1<row;counter1++)
		{
			ptrA[counter1] = calloc(column,sizeof(int));
			ptrB[counter1] = calloc(column,sizeof(int));
			ptrC[counter1] = calloc(column,sizeof(int));
		}
		for (counter1=0;counter1<row;counter1++)
		{
			for (counter2=0;counter2<column;counter2++)
			{		
			       printf(" \t");
			       scanf("%d", &ptrA[counter1][counter2]);
			}

>>any idea how to get this thing straight?
Yes -- do not type <Enter> after each number

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
int main(int argc, char*argv[])
{
   ofstream out;
   if( argc == 2)
   {
      out.open(argv[1]);
       if( !out.is_open())
       {
           cout << "Failed to open the file \"" << argv[1] << "\"\n";
           return 1;
       }
   {
   else
   {
        cout << "usage: myprog filename\n";
        return 1`;
   }
   // now write to the file
  ...
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Learn to read MSDN articles You will have to test each checkbox to determine its state (checked or unchecked)

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

You need VC++ 2005 or 2008 Pro or better edition because that project uses MFC. Express edition can not compile it. If you have the compiler then just double-click PBXClient.vcproj

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

If you are USA citizen or legal immigrant then join the US military. They will give you all the free training you will want. Most colleges and universities in USA have Cadet programs that let you attend college full time and give scholarships to help pay for tuition etc. I know medical doctors who got their medical degree free via military programs. Well, maybe not exactly "free" ... it cost them about 10 years of their life on active duty.

Rashakil Fol commented: lol :D +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

never heard of such a thing, most likely because it would be grossly inefficient. The library at www.DataReel.com contains client/server code ported to both *nix and MS-Windows, but it uses standard sockets.

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

Hey man -- do a lot of research then write a book so that you can make millions of money :)

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

line 49 of the *.cpp file -- that should probably be /= operator.

When I run your program I get this error

Assertion failed: stackTop != 0, file c:\dvlp\try1\try1\stackarray.h, line 109
Press any key to continue . . .

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

( confused here on how the mapping is done between read ,write and scanf ,printf. because read/write takes file descriptors, buffers and size of data where as printf and scanf takes the variable lenght args: format strings and arguments)

printf() also takes a file descriptor -- stdin, stdout, and stderr are three file descriptors always available to C/C++ console programs. printf(), scanf() etc do a lot of pre-processing before sending the strings on to the system functions. All the system functions do is read or write data -- they don't do anything else with it. Formatting the data has to be done by the calling functions.

similarly all the dma functions(malloc,calloc, realloc, memset,memcpy, memmove) also uses some built in system calls.
i just want to know is there any source that describes the library functions and whose corresponding system calls on different OS's.

There are descriptions of the system functions for each operating system, but you won't find them all in one convenient document. You will have to study each os that you are interested in.

Gaiety commented: your post are so help full, thanks a lot +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I began learning MFC from Microsoft's Scribble Tutorial

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

1) Either Code::Blocks or VC++ 2008 Express, both are free

2) MS-Windows. *nix has little support for serious games

3) Tons of sites. Can't recommend any because I don't write games.

4) No. It should be in the IT Professional's Lounge.

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

>>can anyone answer this question?
Yes I can do it, but won't.

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

need a quick answer

Then you should have googled for the answer. That question has been asked and answered millions of times.

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

>>2.sizeof is compile time operator. what does that mean ?
It means that its only evaluated when the program is compiled because the result is a const unsigned int.

>>3.what about all other opearators arent they compile time?
Sometime yes and sometimes no. The = operator has to be evaluated every time the program is executed because the result may be different every time. If you initialize a variable when declared, such as int x = 0; then the = operator is a compile time. But if you assign it a math expression like x = (a * b)/2; then it becomes runtime.

>>when can i ignore the paranthesis around the argument.
The parentheses are optional. Whether you use them or not is just a programming style -- either way is correct.

You have to be careful of the sizeof operator because it can sometimes produce a result that you did not intend. For example, the sizeof a pointer is the same regardless of what kind of pointer it is.

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

>>2.sizeof is compile time operator. what does that mean ?
It means that its only evaluated when the program is compiled because the result is a const unsigned int.

>>3.what about all other opearators arent they compile time?
Sometime yes and sometimes no. The = operator has to be evaluated every time the program is executed because the result may be different every time. If you initialize a variable when declared, such as int x = 0; then the = operator is a compile time. But if you assign it a math expression like x = (a * b)/2; then it becomes runtime.

>>when can i ignore the paranthesis around the argument.
The parentheses are optional. Whether you use them or not is just a programming style -- either way is correct.

You have to be careful of the sizeof operator because it can sometimes produce a result that you did not intend. For example, the sizeof a pointer is the same regardless of what kind of pointer it is.

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

I've used a debugger to step through some of the printf() code on MS-Windows and found that eventually it calls win32 api WriteFile(). From that experience I would imagine other functions also eventually call win32 api functions. But those are the details that are compiler-implementation specific. There is nothing in the c or c++ standards that tell compiler writers how to implement the standard functions; they are free to do it any way they want to.

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

Try Code::Blocks. It works ok on Vista, so it will probably be on on Windows 7 too.

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

video of a drunk trying to buy some more beer.

Will Gresham commented: Brilliant +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

maybe you need a better example that describes more accurately what you are trying to do. Maybe something like this???

class base
{
 // blabla
};

class derived : public base
{
  // blabla
};

void foo( base* pBase)
{
   derived* pDerived = reinterpret_cast<derived*>(pBase);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

And what's wrong with leaving it as a short pointer? Casting it as an int pointer will not give it any more precision.

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

what do you mean by "it is not running" ?

Why don't you get rid of that charcater array and read the line directly into the string.

string data;
while( getline(in, data) )
{

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

short* pnum = static_cast<short*>(&const_cast<short&>(someFunction())); or this const short* pnum = static_cast<const short*>(&someFunction());

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

Another reason not to use Turbo C for Windows programming -- it can not be use for that. Turbo C is a 16-bit compiler and can not access any of the 32-bit MS-Windows libraries or DLLs.

I didn't realize Turbo C++ Explorer is no longer available. It must not have become very popular, nothing like its predecessors Turbo C or Turbo C++.

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

I don't see any reason to have an icode button -- what's so difficult about just typing them in as you type? I don't use the code tag button either for the same reason. I can just type the tags by the time I have to remove my hands from the keyboard, find the mouse, move it to the button, click it, move the cursor between the two tags, move my right hand back to the keyboard, and begin typing again. All that's just too much effort.

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

column names of the table should not be enclosed in quotes.

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

Probably yes, see the functions in graph.h. As for ebooks, you might get some of these for Turbo C

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

In sprite.h the vertices and colours arrays can not be initialized in the class like that. It doesn't work the same as global variables. You have to put the initialization code in the class constructor.

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

If you don't free() the memory before leaving that function then yes, there will be memory leak.

In c++ program you should use new and delete[] instead of malloc() and free().

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

just create an array of 10 integers. Then create a loop from 0 to 10000. Inside that loop generate a random number. Then in a series of if statements find out which range the number is in and increment the corresponding counter.

Anyone with a football avatar should be able to do it, unless of course you are only in school to play sports :)

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

you have to keep track of 10 ranges. Every time you generate a new random number check to see which of the 10 ranges it falls in and then increment that counter. Once you get that done and working right it should be not too difficult to print out the histogram.

The problem with that program is that the histogram isn't very pretty because, on average, with 10,000 random numbers each range will contain about 1000 numbers. And each line of the histogram will have about 100 '|' symbols.

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

Lets say you want to write the class out to a file, then overload the << oeprator

class derivedClass: public abstractClass 
{
public:
    friend ostream& operator<< (ostream& out, derivedClass& cl);
};

// in the implementation file

ostream& operator<< (ostream& out, derivedClass& cl)
{

   out << cl.payRate << " " << hoursWorked << " " << overtime
        << lname << " " << fname << " " << empID << "\n";
   return out;
}

Now do something similar with the >> operator.

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

lines 33 and 34:
>>char *c;
>>c = &line[0];

That is not necessary. Just pass line.c_str() to the function on line 39

line 71: all you have to do is use isdigit() function if( isdigit(*c)) line 82: get rid of all that crap and use isalpha() if( isalpha(*c) ) The program is missing a set of { and }

bool primary (const char *c)
{

     if(integer(c))
        return true;
     else if (literal(c))
          return true;
     else if (*c == '(')
     {
          ++c;
          if (expr(c))
          {
             ++c;
             if (*c == ')')
             {
                ++c;
                return true;
             }
             return false;
          }
     }
     return false;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Which operator do you need to overload? Such as, do you need to write and read the classes to file? IN that case you could overload the << and >> operators.

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

>>for( int i = 0; i < argc; i++ ){
Start that loop at 1, not 0, because argv[0] is always the program name. So there is no use trying to test it.

>> if( strcmp( argv, "--lines-per-page") && i < argc ){

Two things wrong with that.
1) strcmp() returns 0 if the two strings are the same. so you need "== 0" in that statement
2) testing for i < argc is unnecessary because that is taken care of in the for statement
This is what you need: if( strcmp( argv[i], "--lines-per-page") == 0) { >>i += 2;
That is skipping too many values. just use ++i

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

The loop starting on line 73 is wrong. eof() doesn't work the way you think. And you don't need that third parameter '\n' to getline() because that is the default.

while( getline(nameFile,input) )
{
   // blabla
}
nameFile.clear(); // clear error
nameFile.seekg(0, ios::beg); // back to beginning of file

After reading the end-of-file, you have to clear the stream error and set the file pointer back to the beginning of the file so that the file can be re-read. See above code snippet how to do that.

Also, move the open statement up before line 64 so that you only attempt to open the file once.

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

>>the program adds the last number "5" twice

That's because you are wrote the loop incorrectly. Do it like this:

while ( InputStream >> n )
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

single characters take ' and ', not " and ". if( y == '1' )

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

Your first program worked correctly for me using vc++ 2008 express.

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

If you used g++ on linux then you should probably use Code::Blocks with MinGW compiler on Windows.

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

I am using console application. I just want to display my final result with a small form window. There is no need any button. when i close the program, then i will close. I could able to show my result with messegebox. but problem is, it have button and every time need to press button and then it execute next. I already mentioned, i used a loop and every 5 seconds, the result is changed. Could anybody tell me, what is easiest way to solved the problem.

Thanks

You can't make a window except message box if its not a Windows GUI program.

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

With 112 posts I know you know how to use code tags. Then edit your code to correct all the typing mistakes you made when posting those classes.

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

Here is how to open the file in main(), assuming the filename is in argv[1].

#include <fstream>
using namespace std;

int main(int argc, char* argv[])
{
    ifstream in(argv[1]);

}