hacker9801 49 Junior Poster

If you use the new operator on a class, say

class dummy { public: string f; };
int main(int argc, char *argv[]) {
  dummy *p = new dummy;
  return 0;
}

do you have to use the delete operator on p ? (since, apparently, it utilizes new.)

hacker9801 49 Junior Poster

Well it's better to learn a multi-platform GUI library than Win32 functions.

For example, Qt, GTK+ and wxWidgets all work on Windows and Linux, and I'm sure Mac too.

I hate Qt though, had a hard time with it. :P

hacker9801 49 Junior Poster

um, trying to exploit Google page rankings is a significant problem even for experts.. as a "beginner", you'll be better served trying to program a Sudoku game or something...

but, if you're really intent on trying to hack some websites, most SkriptKiddi3Z prefer Perl for this sort of task...


.

I don't think that's what he wants to do.

I think he wants to make a macro to put something in google?

hacker9801 49 Junior Poster

#pragma once is the better way of doing it. ifdef, endif are outdated.

not at all. :) #pragma once is only supported by a few compilers. #ifndef, #define and #endif are supported by all compilers. :)

Salem commented: Good answer - #pragma is non-portable +16
hacker9801 49 Junior Poster

...
num1 is already of int type, you WOULDN'T be able to enter a character anyway.

jephthah commented: a char is an 8-bit integer. get your basic facts straight before "helping" please +0
hacker9801 49 Junior Poster

I know the & operator means address-of, but what's it do when in a function prototype?

Example:

void foo(std::string& str)

or

void foo(char& c)

what's the & for in that?

hacker9801 49 Junior Poster

C# is a Microsoft language, part of the .NET family.

hacker9801 49 Junior Poster

strrev is deprecated (OLD OLD OLD)

use

int num = 5; // number
char buffer[1000]; // this is where the integer is converted to

itoa(num, buffer, 10);
hacker9801 49 Junior Poster

is grid an array chars?

cout << (grid[r][c] == '1') ? '1'  : '*' << ' ';

or

if(grid[r][c] == '0') cout << '*';
else cout << '1';
hacker9801 49 Junior Poster

Your IDE is Visual C++ 6.

1) Yeah, copy fmodex.dll into your project dir\bin

2) Yeah, copy the name of the library. To link one, just add #pragma comment(lib, "libraryname.lib") in your main source file (forgot how to do it the other way).

3) Yeah, but there's a few of them so it's best to put them in an fmod/ directory.

hacker9801 49 Junior Poster

Well the function is correct, if it doesn't work you should make sure the data is filled in correctly.

hacker9801 49 Junior Poster

What exactly is it doing & what is the expected output?

hacker9801 49 Junior Poster

You're not calling it. To call a function, use, for example, cd3.returncosts()

hacker9801 49 Junior Poster

Go to "C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api" - assuming you're on Windows - and copy fmodex.dll to your binary directory (one with your compiled .exe).
Then go to the lib directory and read "which library do I use.txt", copy that to your working directory and import it into your IDE as a linker library.

Then go back and go to the inc directory, copy all of that and make a new directory in your source directory called "fmod", then try to compile it.

(sorry I'm not good at explaining things.)

hacker9801 49 Junior Poster

Wow, they got root? How?

hacker9801 49 Junior Poster

your coding style is terrible. Don't be afraid to use more white space -- it won't slow down the compile time any and won't take up any more room on your hard drive.

Seconded. :P

hacker9801 49 Junior Poster

it'll take 6-12 months to make a simple bot in c++? wow.

What, you think it's a slice of cake? :icon_rolleyes:

hacker9801 49 Junior Poster

You can get FMOD from here.

But if you don't use Visual Studio you need to use the C API, not the C++ one.
I used fmod once, it's pretty easy and straightforward. Here's some of my test code. I compiled it in Dev-C++.

#include <cstdlib>
#include <iostream>
#include "fmod/fmod.h"
#include "fmod/fmod_errors.h"
using namespace std;

FMOD_RESULT result;
FMOD_SYSTEM *fsystem;
FMOD_SOUND *sound;
FMOD_CHANNEL *channel;

void fmod_err(FMOD_RESULT result) {
     printf("Error in FMOD: (err=%d) %s\n", result, FMOD_ErrorString(result));
     exit(1);
}

void ERRCHECK(FMOD_RESULT result) {
     if(result != FMOD_OK) fmod_err(result);
}

void stuff() {
     // do stuff with FMOD
     
     // load sound
     result = FMOD_System_CreateStream(fsystem, "linch.mp3", FMOD_DEFAULT, 0, &sound);
     ERRCHECK(result);
     
     result = FMOD_System_PlaySound(fsystem, FMOD_CHANNEL_FREE, sound, false, &channel);
     ERRCHECK(result);

     /* fmod doc says to do this, but I don't (and it still works fine) I guess it updates channel info:
     while(true) {
         FMOD_System_Update(fsystem);
     }*/
}

int main(int argc, char *argv[])
{
    //FMOD_RESULT result;
    
    result = FMOD_System_Create(&fsystem);
    if(result != FMOD_OK) fmod_err(result);
    
    result = FMOD_System_Init(fsystem, 5, FMOD_INIT_NORMAL, 0);
    if(result != FMOD_OK) fmod_err(result);
    
    stuff();
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}
hacker9801 49 Junior Poster

Wow, I noticed it got hacked too. And yet the admins don't post any threads.... shame shame shame...

I think your passwords are safe.

hacker9801 49 Junior Poster

Yeah (thanks), but the problem is I don't know how I'd recieve them.

I don't really need to throw them in a Packet struct; I just need to parse out a command / body. I need a way to parse out cmd len body from the socket stream and deal with it in my code.

It really doesn't matter - right now I'm using strings & newlines to send data thru a socket, I just want a better protocol.

hacker9801 49 Junior Poster

....
for sound use fmod or something, you can't do video in a *console* application.

hacker9801 49 Junior Poster

anyone? it shouldn't be too hard...

hacker9801 49 Junior Poster

55: should be openInputFile("infile.dat"); (even then it won't work, infile.dat is a string not an ifstream reference) just take this line out and it should be fine.
77: if (strcmp(array[index], minValue) < 0)) you have an extra )

74:error: Stropy was not declared in the scope
77:error: Stromp was not declared in the scope

What? In your code it says strcpy and strcmp , if not change it.

hacker9801 49 Junior Poster

.......it's not hard at all.

(edit: lol a little late, sorry I was reading the other thread)

hacker9801 49 Junior Poster

Hey. I want to make a packet structure, something like

struct Packet {
  int cmd; /* command */
  int len; /* length of body */
  char body[30]; /* body (should be length of len though, might use std::string) */
};

Now, if I recieve some data thru a socket (I'm using some socket class based on Winsock2 and for the client SDL_net) read data (command, length & body) into a Packet structure?

Basically I'm wanting the socket stream to look like cmd len body for example 0x01 0x05 hello , but I don't know how I'd parse that into a Packet structure.

hacker9801 49 Junior Poster

Do you need to memset() movem to null?

I'm not sure, I'm pretty much a beginner at C++. I'd compile it if it had newlines in the code tag...

hacker9801 49 Junior Poster

I didn't read it all but change the line in main to:

getData(marital, numChild, exempt, noOfPeople, groSalary, penAmt);

Don't put the data-types in the function calls

edit: and you re-declare alot of stuff......

hacker9801 49 Junior Poster

>
Suzumiya Haruhi no Yuutsu.

Yeah, why do you have a Kyon avatar? Nice quality though.

Also I hate the noobs that label everything as urgent.

hacker9801 49 Junior Poster

Well, it really doesn't matter.

I don't like doing for(int i=0;i < players.size();i++) { if(players.at(i).id == p_id) { ... } } , I was thinking just use SQL to do SELECT * FROM players WHERE id = '<p_id>' and stuff.
(but; I store the players socket inside the vector, so I guess I'd still need to store id/socket in them.)

I have MySQL installed, but I don't have the C/C++ headers or library. Where do I get those, anyway?

hacker9801 49 Junior Poster

Hey. Right now in my game (online) I'm using std::vectors to store player info.

Should I continue to use them (I hate having to loop thru them each time to find a player) or should I use MySQL to hold player information (like map their on, nickname, id, position, etc.)?

hacker9801 49 Junior Poster

Here's a working example (I wrote in ~5 minutes), but write your own and use mine as an example on a way to approach it.

#include <cstdlib>
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    char value[50] = {0}; /* our character array */
    char c_tmp[2] = {0};
    char c; /* character to count */
    
    while(strcmp(value, "$") != 0) { /* keep looping until value is $ (then stop) */
        memset(value, 0x0, sizeof(value)); /* empty value (null it) */
        
        int num = 0; /* numbers of times it appeared */
        
        cout << "enter a character: ";
        cin.getline(c_tmp, sizeof(c_tmp));
        
        c = *c_tmp;
        
        cout << "enter a sentence: ";
        cin.getline(value, sizeof(value));
        
        for(int i=0;i<strlen(value);i++) {
                if(value[i] == c) num++;
        }
        
        cout << c << " appeared " << num << " times." << endl;
    }
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}
hacker9801 49 Junior Poster

I like Lua. It's easy to implement in C/C++ and can call C/C++ functions if you register them.

But if Python is easy to implement, it's alot more powerful; and generally easy to script.

hacker9801 49 Junior Poster

bump...

hacker9801 49 Junior Poster

>Small quick reply box
That's why it's quick.

>leet speak
101 \/\/|_|7 15 \/\/R0/\/G \/\/17|-| 7|-|15???11/!?!/1/!?!?

> People dumping thousand lines of code
seconded.

hacker9801 49 Junior Poster

Right, right; but what if the user requests a couple maps and they all get messed up? :p

Also, I don't really like using strings for socket data. Do you have an example of using hex or whatever in them?

hacker9801 49 Junior Poster

Mastermind.

hacker9801 49 Junior Poster

Like everyone else, I hate people that don't use code tags. Seriously, is it that hard?

hacker9801 49 Junior Poster

Well, I'm sending:

  • map:map.xml for when a player changes maps
  • move:x:y for when a player moves
  • chat:text for when a player says something
  • kick:player and ban:player
  • mode:player:mode a mod function

etc, etc.

hacker9801 49 Junior Poster

Thanks for your reply.

I guess I could do something like that ( #define F_POS 0x01 , #define F_UPDATE 0x02 etc.)

But how would the server parse that? Sorry, I'm new to this. Right now it sends strings, like "move:x:y" and stuff.

How would I make the server parse that, then parse the length, etc etc?

hacker9801 49 Junior Poster

How about XOR encryption? It's a nice way to encrypt files.

hacker9801 49 Junior Poster

Hey all.

I'm making an online game. It uses XML maps, and I was wondering...

what's the best way to transfer an XML file over a socket?

I want my server to send an XML map whenever it's requested, but I dunno how I'd get the xml from the other data sent by the server. (the map is probably 30kb and my client pulls in data at 1kb each time).

Any ideas?

hacker9801 49 Junior Poster
char buf[100];
int i;

strcpy(buf, "foo");

i = atoi(buf);

that?

hacker9801 49 Junior Poster
BloodDonor(long=0 ,string ="",string ="",string ="",string ="",int =0,int =0,int =0,string ="",string ="");

don't think you can set default types in c++

hacker9801 49 Junior Poster

Well, for fairly small files you can store them in a BLOB field in MySQL.

hacker9801 49 Junior Poster

How about FMOD or something...

Also, MySQL is easy. Anyone can learn it, so just read a few tutorials.

hacker9801 49 Junior Poster

Python is an awesome scripting language, and it's very extensible.

I used to use it all the time, but now I'm learning C++. I wouldn't touch java, it's JVM is slow (IMO slower than Python's interpreter) and it's just terrible.

hacker9801 49 Junior Poster

try putting global gold as the first statement in any function that uses the variable 'gold'

hacker9801 49 Junior Poster

also, you need to set length , use strlen() for that.

hacker9801 49 Junior Poster

The beep is due to an ASCII character, consoles read it as a beep.

I dunno how you can stop it, though.

hacker9801 49 Junior Poster

use code tags, also.