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

One afternoon, a lawyer was riding in his limousine when he saw two men along the roadside eating grass. Disturbed, he ordered his driver to stop and he got out to investigate.

He asked one man, "Why are you eating grass?"

"We don't have any money for food," the poor man replied. "We have to eat grass."

"Well, then, you can come with me to my house and I'll feed you," the lawyer said.

"But sir, I have a wife and two children with me. They are over there, under that tree."

"Bring them along," the lawyer replied.

Turning to the other poor man he stated, "You come with us, also."

The second man, in a pitiful voice, then said, "But sir, I also have a wife and SIX children with me!"

"Bring them all, as well," the lawyer answered.

They all entered the car, which was no easy task, even for a car as large as the limousine was.

Once underway, one of the poor fellows turned to the lawyer and said, "Sir, you are too kind. Thank you for taking all of us with you."

The lawyer replied, "Glad to do it. You'll really love my place............

The grass is almost a foot high."

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

since when did you think that removing guns out of the hands of law abiding people will make the world a safer place? What did people use to kill other people before the gun was invented? Are we also to ban knives, bows & arrows, and rocks? Remember, it was the Chinese who invented gun power, not Americans. And it was in 1718 in London that the pickel gun was invented.

And how about this story of the little old 81-year-old lady who shot off the testicals of a rapist. There have been a lot of similar stores where guns prevent crime. So you think she should have called the police?? The police are not our personal body guards -- its our own jobs to protect ourselves.

EnderX commented: Nicely put, and interesting link. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The only reason to monitor rep comments is to filter out objectional language and the language filter should do that. Otherwise I could care less about the comments, other than to read them and possibly find out any problems I may have caused.

Serunson commented: thanks for the rep! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

this could be true, and probably is true. but it could be the message we send that does the most good.

you are just kidding yourself if you think that will do any good. Its been tried before and nothing at all happened to gas prices. Big oil companies could care less what we the consumer think -- they can charge anything they want and we are stupid enough to pay it. $3.00 per gallon is nothing compared to european prices. Last time I heard it was over $10.00/gallon in UK.

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

>>is this the right way?
No because atoi() takes a pointer to a null-terminated string and your variable temp is just a single character.

The quickest way is to simply subtract the ascii value of '0' from it like this: int n = temp - '0'; . Why does that work? Its because a char is a small integer and if you look at an ascii chart you will see that all characters have an ascii numerical value. Internally, programs know nothing at all about characters, only numeric values as shown in that ascii chart.

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

It is a resource file for MS-Windows programs, and describes the dialog boxes, controls on the dialog boxes, string tables and other graphic resources used in the program. If you use one of the Microsoft compilers the IDE will generate the .rc file for you and you don't have to worry too much about them. But if you use another compiler such as Dev-C++ you may have to generate it manually. I believe this tutorial has more about resource files.

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

use fgets() instead of fgetc() and your program will work better and be a lot less complicated.

delete line 5, NULL is defined in standard c header files.

remove the braces on lines 11, 12 and 13. They are not necessary there.

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

you have to print each field individually

printf("name: %s\n", Doom3.name);
printf("memory: %d\n", Doom3.memory);
...
blas commented: lol... I cant understand this :P +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Has anyone successfully installed Acrobat Reader? It downloads ok, uncompresses, then gives the error message "The Temp folder is on a drive that is full or is inaccessible. ...". I used command prompt to display the values of all environment variables and the TEMP is in d:\users\<full path here>.

Anyone know a solution to this problem?

Thanks

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

The clock function returns the number of clock ticks that have elapsed since the program started. One clock tick is typically 1 millionth of a second (called a millisecond) but it doesn't have to be. The macro CLOCKS_PER_SEC is the number of ticks per second. So if clock() returns a value of 2000000 then that is 2000000/CLOCK_PER_SEC or 2 seconds.

The line diff = ( std::clock() - start ) / (double)CLOCKS_PER_SEC; is just calculating the difference between the current time and the previous time, then converting it to seconds.

>>it looks like a lot of uninitialized variables
Look closely and you will see that his code initializes the variables correctly. Initializing variables to zero or some other value when declared is a good habit to get into, but its not absolutely required as long as the variables are initialized someplace before attempting to access them.

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

>>void foo( char * ptr)

The problem is that ptr is a local object which has scope only within the function foo(). So the memory allocated with malloc() will be tossed into the bit bucket as soon as foo() returns to main(), and that will cause a memory leak. Inside function main() the value of ptr will still be 0 after foo() returns and the next line, printf(), will probably crash because the second argument (ptr) is a NULL pointer.

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

Here are some tutorials

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

Some example free programs for MS-DOS, MS-Windows in C and assembly

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

Every version of MS-Windows is shipped with a free assembly language debugger. It's located in the c:\windows directory (or wherever you installed the operating system), and named debug.exe

This is a brief tutorial how to use it.

sergent commented: Nice! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

create a bool flag before the loop starts and set it to false. when a swap is made change the flag to true. on next loop iteration if the flag is still false then no swaps were performed during the previous loop iteration.

and please next time use code tags.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
a[2] = a[3] <<< NO NO NO

NO! NO! NO! that is backwards. Look at the loop I posted.

a[3] = a[2]  <<First loop iteration
a[2] = a[1] << Second iteration 

a[1] = new string << final result

The loop counter MUST count down for this to work correctly.

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

HI, I have exe file writen in c++ or c and wanna decompile it to source code.
Is that possible? If it is, is there any decompilet that can do that?

thanks!

No, it is not possible to decompile back to C. The best you can do is get the assembly code. Since you lost the source code (and that happened to me a couple times too!) you will just have to rewrite it. That has some advantages because the second write ususlly makes a better program anyway because you already know most of the algorithms needed and you may be able to make them more efficient.

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

save and restore the original pen value. Some other part of the program may be expecting the pen to be the original value and your program doesn't want to pull the rug out from under it. Your program needs to be a little kinder and a little gentler about other parts of the program.

Grunt commented: Ah, windows guy-[Gr] +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A union is just a structure in which all objects occupy the same space. For example

union 
{
   int a;
   char buf[20];
   float b;
   double c;
}

In the above, the union has only one real object but it can be used by any of the names provided, such as a, b, c or buf. The size of the union is always the size of its largest object, 20 in this case. So what you need to do is make a union between the INSTRUCTION strucure and an unsigned long integer.

uinion
{
    INSTRUCTION ins;
    unsigned long ln;
};

Since sizeof(INSTRUCTION) is the same as sizeof(ln), whatever you set ln to be will be reflected in the ins structure. So if you set ln = 0x8800080000004D2, then you can get the individual bits by using the ins structure.

leonpwhirl commented: helpful in answering questions. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a link I find a useful reference.

Salem commented: rep++ from Salem +2
Killer_Typo commented: great link +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is an example

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

Also see this thread

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

Do you mean Quantlib open source library for quantitative finance ? I don't know a thing about it, but their web site has a lot of information including documentation and links to relevant forums. The site even contains links to example programs.

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

most programs that use passwords display an asterisk for each character typed. Your program probably should do that too, and it can be done within that while loop. If you look at the curses library you might find there it already a function that will do it for you. That loop also needs to check for buffer overflow, do not allow i to exceed the size of input buffer.

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

Assuming you mean MS-Windows operating system, call GlobalMemoryStatus.

Grunt commented: :) [Grunt] +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>char *str="abcd";

There are two objects here -- the pointer itself is a variable that is on the stack. It contains the address of the string that is stored in the heap -- often in read-only memory.

[edit]Sorry Holly I didn't see your last post when I posted this. The link you posted is a much better and thorough explaination.[/edit]

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

probably because BGI requires a 32-bit compiler, which TurboC is not. Upgrade to one of the free compilers mentioned in that link.

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

csv format uses commas between fields, and I believe that text fields which contain commas should be enclosed in quotes.

FILE *fp = fopen( "file.csv", "w" );
fprintf( fp, "%d,\"%s\",\"%s\",\"%s\",%d,\"%s\",\"%s\",\"%s\",%d\n", index, delim, deltime, delim, 
         type, delim, filename, delim, filesize );
fclose( fp );
Grunt commented: Good - [Grunt] +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. do not use feof().
2. your program is mixing binary file read with text file writes. If the file is truly a binary file then simply using fprintf() to write it to another file is not what you want to do.

char buffer[255];
size_t nBytes;
while( (nBytes = fread(buffer,1,sizeof(buffer),fp_infile)) > 0)
{
    fwrite(buffer,1,nBytes,fp_outfile);
 }
fclose(fp_infile);
fclose(fp_outfile);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

any plans to actuvate rep power, like you see on many other boards such as this one?

WolfPack commented: good suggestion +3
hollystyles commented: He's fiery hot +2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

here is a pure c++ version that replaces the C-style char array with std::string and removes the tmp variable altogether.

From the looks of this function it must be just a code snippet of a larger more complex function, is that right? If it isn't, then you can remove vector array because it serves no purpose.

ifstream file(filename);
if (file)
{
    std::string line;
    while ( getline(file,line) )
    {
       vector <string> array;
        istringstream iss(line);
        int i=1;
        while ( getline(iss, token, ',') )
        {
            array.push_back(token);
            v_List.SetItemText(nItem, i, token.c_str());
            i++;
        }
 }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is simple code to get all the file names in a directory. It does not parse sub-directories.

WIN32_FIND_DATA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
char DirSpec[MAX_PATH]; // directory specification

strcpy (DirSpec, argv[1]);
strcat (DirSpec, "\\*");
HANDLE  hFind = FindFirstFile(DirSpec, &FindFileData);
if (hFind != INVALID_HANDLE_VALUE)
{
   do {
      // If this filename is NOT a directory
     if(!FindFileData.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY)
    {
          // do something with the filename

    }
  } while( !FindNextFile(hFile,&FindFileData);
  FindClose(hFile);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I agree that a delete button would be useful -- I have occationally posted bad information and the only way to delete it was to edit the post and remove all the code, leaving a post with an empty message.

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

set a timer event for the amount of time you want it displayed, then in the event handler kill the message box -- send it WM_CLOSE event.

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

This might help -- shows different file formats.

NicAx64 commented: thanks for the site , I everyday learning something by digging your thread ha ha ! +1
piriyanka commented: super good +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

A factorial is n * (n-1) * (n-2) * .... so all you need is a simple loop to calculate the factorial

long n = 5;
long total = 1;
while(n > 1)
{
  total = total * n;
  --n;
}
// output result
cout << total << endl;

[edit]Sorry about duplicating a previous answer. I didn't see them when I posted this. :( [/edit]

<M/> commented: your very first post :D +8