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

1) name is an uninitialized pointer. You have to allocate memory for it before it can be used as an input string (line 14). Just declare name as a character array instead of a pointer, such as char name[80]; line 11: There is no reason to make that variable a pointer since all you want is 10 floats. Just declare it as an array float array[10]; line 12: You can just delete this line if you make that variable an array of floats as above. In c++ programs you should use the new operator instead of malloc() or calloc().

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

Can you link me to a site?Please note I want to open the standard musical sounds like:cymbal crash.base drum sounds.

google for them.

If all you want are the sound files, then try these

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

any body have any good way to learn it?

Yes --

  • Buy a book and read it.
  • Go back to college and take a few programming courses
  • Read some online tutorials
  • Stop spamming your sig links
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>if anyone could help me get the code correct and working would be really great.

You need to state the problem(s) you have with the code and post a few of the error messages your compiler produced. We are not here to do your homework for you.

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

>>fatal error C1083: Cannot open include file: 'ffmpeg/swscale.h': No such file or directory

It should have been pretty obvious that the compiler can not find one of the include files. Check your computer and find out if you have swscale.h

>>error C3861: 'mkdir': identifier not found
You need to include the header file that declares mkdir()

>>error C3861: 'getopt': identifier not found
My guess is that the program was written for *nix. For MS-Windows or other operating systems you may have to write your own version of getopt(), or find a freeware version on the web.

Kreddy89 commented: that was helpful. thank you. +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

dude i knw hw to speak/explain in english...
n also the prblm m facing...
may b u r not undersatanding

obvsly nt sc y cnt wr a dcnt sntce.

jonsca commented: Nice +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

i using windows xp i install the turboc when i click tc but it open and close immediately

Good :) Now get yourself a newer free compiler such as Code::Blocks/MinGW or VC++ 2008 Express.

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

you need to include windows.h, not ole32.h. Here are the changes you need to make to stdafx.h. Notice I deleted the line I suggested previously because windows.h forces all the necessary libraries.

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

// TODO: reference additional headers your program requires here
#include "windows.h"
#include <stdio.h>
#include <iostream>
#include <tchar.h>
#include "bridge.h"
using namespace std;
Nick Evan commented: Nice one :) +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Agni commented: Nice article..!!! +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

change line 4 to this: #define DLLEXPORT __declspec ( dllexport ) Now you will have a normal c++ function, which of course can not be called by any C program. But you will still want to change the return value so that it returns std::string instead of std::string *.

cwarn23 commented: Great help and advice +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

memory allocated with new or malloc() in a DLL can not be deallocated by the main program because the memory has to be deallocated in the DLL. The same with memory allocated in the main program has to be deallocated there, the dll can not do it. The reason is because they are from different memory pools.

So the thing you should do for that function is to return the std::string object, not a pointer to it (just remove the star) and delete line 38. DLLEXPORT std::string explode (std::string exploder, std::string original, int limit=0) { Here is another thread about that discussion

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

Energy cannot be destroyed , it can only change forms

And the Earth is still flat :) Scientific thought tomorrow may prove that statement false.

God being all-powerful could have made Earth, the universe, physics, science, everything give humanity (and any other intelligent life elsewhere in the universe) the exact answers we've found.

Which, of course, proves the universe is a lot older than 6-10,000 years. Or did God contradict himself? I doubt that, instead it is man who misunderstood the teachings in the Bible.

Who's god?

There is only one God -- All those others you may have heard about are just variations of the same God.

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

An interesting and mind-boggling thread. When God created the universe 6,000 years ago He made it look like the universe was 16 billion years old. Yea, right :)

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

Hi,
If you delete the backup partition and you need to reinstall Windows, you will then need to buy a new OS or computer so it is best left alone.

Not true. I lost my HD on my HP computer, called HP tech support and they mailed me a DVD that restores the os (Vista Home Prem) back to factory settings -- cost me $25.00 but it worked. I could have saved myself that money and made it myself when I first got the computer, but dummy me didn't do it. It also took me about 24 hours to completly reinstall Vista.

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

lines 60 and 61: you don't need both of those lines -- delete one of the two.

line 67: you are mixing up files opened in text mode and files opened in binary mode. read() method is for binary mode, not text mode. If it is really a binary file then you need to add ios::binary flag in the open statement like this: file_in.open(file_in_name, ios::binary); line 76: you need to use the value returned by gcount() instead of just hard coding the number 16 because the last read may or may not be 16, and anything between the number of bytes actually read and 16 will just be garbage.

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

Is that dll file *.c or *.cpp file? If it's *.cpp then the function prototype in your program should not use extern "C" because that changes the function name.

Silvershaft commented: Nice help thanks! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just as I suspected. Only static methods can be passed to that C function. Make the function error static and it will probably compile ok.

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

Put your finger on the Shift key, scroll down with the mouse to highlight all the items you want, then press the Delete key. Or you could just delete them all then rebuild the inventory page.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
#include <windows.h>

int main()
{
   HWND hWnd = GetConsoleWindow();
   ShowWindow(hWnd,SW_HIDE);
}
Excizted commented: Useful! +1
pspwxp fan commented: do u have such an easy solution 2 everything? +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>This code is wrong.
There are as many ways to do something as there are programmers to do it. What exactly is wrong with the code I posted? Post a link to the article you site.

BTW there is no such thing as an "MSDN Official sample". They just provide samples, there is nothing "official" about them.

[edit] reparse points have nothing at all to do with the topic of this thread. So it becomes obvious you don't have the slightest clue what you are talking about.

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

This shows how to get the size of all the files in a folder, and all its sub-folders on MS-Windows operating system. It uses recursion to transverse all the directories, and return a 64-bit integer. It was compiled with VC++ 2008 Express and Code::Blocks Version 8.02 with MinGW compiler.

Excizted commented: Useful code snippet. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Search these forums because the solution has been posted several times.

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

Nobody is just going to give you all that code. First you have to decide what the program will do -- design the menus, screen layouts, etc. Write it down on paper so that you don't get confused. Once you are finished with that then you can begin to write the program.

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

You don't have the time nor the skills to tackle large games, Here are some links that might help you.

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

>>So what really decides the size of an exe file.
Your compiler. Two different compilers using the same identical code can produce different exe sizes. And the same compiler can produce different exe sizes depending on the flags you give it, such as DEBUG and UNICODE, and the way it might optimize or not optimize the code.

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

Post what you can do and ask questions about what you can not do. Also tell us what compiler you are using.

#include <stdio.h>

int main()
{
   // write our program here

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

Wer can i know more details about that lint program ????

google

Salem commented: Simple and obvious really :) +17
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I created a new C console project with Code::Blocks and it did not produce a warning or error on malloc(), just as I had suspected. Then I created a new C++ console project, changed the file extension to *.c and Code::Blocks produced an error like you said. Apparently the compiler doesn't know that *.c is a C source file, not c++. So you obviously created the wrong kind of console project.

nt main()
{
    char *ptr = malloc(25); // no warnings or errors here
    strcpy(ptr, "Hello World");
    printf("%s\n", ptr);
    free(ptr);
    return 0;
}

>>157 I don't understand what you mean, I allocated the memory of c at line 142

No you didn't. line 142 declared a character array ON THE STACK and such arrays can not be used in the return statement. Even if you allocate new memory for c using malloc you still can not return a pointer to somewhere in the middle of that array because the original pointer will be lost and result in a memory leak. The only way to successfully return a character array is the way I mentioned. Well, there is another way but it is a little more complicated -- pass the pointer by reference to that function

const char *getWord(int wordN, char** retvalue) {
...
...
  if( retvalue != NULL)
  {
      // deallocate the pointer if necessary
      free(*retvalue);
     *retvalue = malloc( ... );
     return *retvalue;
  }
}

int main()
{
    char *ptr = NULL;
    
    char* word = getWord(wordN, &ptr) …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its not possible to delete just the parent -- when you delete the child then parent gets deleted too. Both parent and child form a single object, not two.

Excizted commented: Quick, straight as always :D Thanks. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are suggesting a blackball list? Or a hit list? Just because someone doesn't mark the thread solved, reply, or post a thank-you doesn't mean your post was not helpful or unread. Of all the 10 thousand threads I have posted in only 1500 of them were marked solved, or roughly 15%. Are you saying the other 85% should be on my hit list?

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

>>invalid conversion from *void to *char
You must be compiling that program as c++, not C (filename has extension *.cpp, not *.c). C does not require typecast, c++ does. Rename your program to have *.c extension and you will not get that error.

>>so I didn't add that part into the code.
Big big mistake. So instead of correcting your program you decided to just leaved the bugs in.

line 157: That return will cause program crash because it is returning a pointer into array c, which will get destroyed as soon as that function returns. You need to allocate new memory and return a pointer to it.

char* p = malloc( strlen(token)+1);
strcpy(p, token);
return p;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 7: >> char getWord(int wordN) {

All getWord() will return is a single character. What you want it to return is an entire string, so declare it like this: char* getWord(int wordN){ I think you want arofstr to be an array of 200 strings. Then declare it like this: char* arofstr[200] = {0}; That is an array of 200 pointers, and each pointer is initialized to NULL.

line 40: you will have to copy the entire string to the pointer -- the = symbol will not do that.

arofstr[f] = malloc(strlen(token)+1); // allocate memory for the string
strcpy(arofstr[f],token);

line 51: You need to free() all the strings except the one that you want to return.

int i;
// free all the memory allocated for the strings
// It is ok to pass a NULL pointer to free(), so you
// don't have to test for that.
for(i  = 0; i < 200; i++)
{
    if( i != wordN)
         free(arofstr[i]);
}
// now you can return the string
return arofstr[wordN];

line 57: its int main(). Most modern compilers will complain if you declare it anything else.

line 65: >> char guessWord[] = getWord(wordNumber);
You have to use a pointer here: char* guessWord = getWord(wordNumber); or you could copy it

char guessWord[255];
char* ptr = getWord(wordNumber);
strcpy(guessWord,ptr);
// now free up the memory returned by that function\
// to avoid memory leak.
free(ptr);

line 67: >> int wordlength = sizeof(guessWord) - 1;
Can't …

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

>>Here's a question for you.
Not for me -- I already know how to do that.

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

>>I've been searching for this on Google for about two weeks now and keep coming up dry

You mean you have been googling for two weeks and never tried this? :icon_eek: Read the first link you see.

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

use cout

int x = 12345;
cout << x;
Nick Evan commented: Sounds like a plan :) +11
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 57 and 58: you do not have to initialize the arrays one letter at a time -- just do the entire string at one time

char currentWord[] = "......"; /* The dot word */
 char guessWord[] = "monkey"; /* The word that needs to be guessed */

line 65: >> while (currentWord != guessWord) {
You can not compare two strings using the != or == operators. You have to call the function strcmp(), like this: while( strcmp(currentWord, guessWord) != 0){ strcmp() returns 0 when the two strings are identical (including letter case).

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

You can erase an element from the map, but you can't delete just one of the pointers because it belongs to an array. If you allocate the pointers one at a time then you could delete them in any order you want.

map<int,particle*> particle_map;
for(i==0;i<number_of_particles;i++)
{
   particle_map[i] =   new particle;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

That is Wal-Mart this year -- no Christmas music and no Christmas tree at the front doors. Its really sad that Wal-Mart isn't in the Christmas spirit this year.

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

You need an account on tweeter.com to make that work. It worked for me. BTW I'm Superman :)

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

You could just say p1 = right.p1; but that could be dangerous if right ever goes out of scope or is destroyed. A safer approach is to allocate new memory for p1 and copy the contents of right.p1 into it.

A& operator=(const A& right)
{
    A a;
    a.p1 = new C;
    if( right.p1 != NULL)
       *a.p1 = *right.p1;
    return a;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What is wrong is that you are using some crappy compiler such as Turbo C to run an MS-Windows 32-bit program. Can't be done. Toss out that compiler and use a modern compiler such as Code::Blocks (with MinGW compiler) or VC++ 2008 Express -- both are free.

Also: the / character can not be escaped -- just delete the \ before /

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

I have no idea what he is trying to say -- just looks like a lot of gobbledegook.

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

you forgot the case keyword. Your program contains millions of other errors that you need to correct -- if your compiler doesn't report them then toss out that crappy compiler and get one that actually works right.

int area(shape *s)
{
 switch(s->st)
    {
        case RECTANGLE:
            return (s->shape_u.rect.side1) * ( s->shape_u.rect.side2);
        case SQUARE:
            return (s->shape_u.squa.side) * (s->shape_u.squa.side);
        case CIRCLE:
            return (int)(s->shape_u.circ.radius * 2 * PI);
        default:
            return -1;
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is another way to do it.

string space2underscore(string text)
{
    for(int i = 0; i < text.length(); i++)
    {
           if( isspace(text[i]) )
                text[i] = '_';
    }
    return text;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What is going on in that code is called undfined behavior and will not work. Why? Because ptr is an uninitialized pointer, and dereferencing it like *ptr = (put anything here) is illegal and will most likely crash the program.


The second problem with that code snippet is *color++; on line 6. Variable color is not a pointer so it can not be incremented. The compiler should produce an error on that line.


line 1 is an error because a single integer can not be initialized with multiple values. color progably needs to be an array, like this: int color[] = {1,2,3};

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

create a union

// declare types
enum data_types {
    undefined_type = 0,
    bool_type,
    char_type,
    short_type,
    ushort_type,
    int_type,
    uint_type,
    // etc for each type you want to support
};

    

struct data
{
    data_types valid_type;
    union types
    {
         bool b;
         char c;
         short s;
         unsigned short us;
         int i;
         unsigned int ui;
         long l;
         unsigned long ul;
         long long ll;
        float f;
        double d;
   };
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to declare them extern "C".

#ifdef  __cplusplus
extern "C" {
#endif
// C function prototypes here
#ifdef  __cplusplus
}
#endif

You will find this example in stdio.h as well as other c header files that may also be used in c++ functions.

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

When I come to DW I have the C++ forum bookmarked. So the first thing I do is look at the threads in that forum to see if I need to reply to any of them (via the New button). Then I'd use the Favorite Forums links to do the same with the other favorite forums. In the 4+ years that I have been a member here I think I may have visited the DW Home page 5 or fewer times.

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

If you need the space, get rid of "Most Recently Viewed Threads" and put back My Favorite Forums.