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.)
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.)
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?
#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. :)
...
num1 is already of int type, you WOULDN'T be able to enter a character anyway.
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?
C# is a Microsoft language, part of the .NET family.
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);
is grid an array chars?
cout << (grid[r][c] == '1') ? '1' : '*' << ' ';
or
if(grid[r][c] == '0') cout << '*';
else cout << '1';
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.
Well the function is correct, if it doesn't work you should make sure the data is filled in correctly.
What exactly is it doing & what is the expected output?
You're not calling it. To call a function, use, for example, cd3.returncosts()
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.)
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
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:
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;
}
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.
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.
....
for sound use fmod or something, you can't do video in a *console* application.
anyone? it shouldn't be too hard...
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.
.......it's not hard at all.
(edit: lol a little late, sorry I was reading the other thread)
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.
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...
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......
>
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.
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?
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.)?
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;
}
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.
>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.
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?
Like everyone else, I hate people that don't use code tags. Seriously, is it that hard?
Well, I'm sending:
map:map.xml
for when a player changes mapsmove:x:y
for when a player moveschat:text
for when a player says somethingkick:player
and ban:player
mode:player:mode
a mod functionetc, etc.
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?
How about XOR encryption? It's a nice way to encrypt files.
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?
char buf[100];
int i;
strcpy(buf, "foo");
i = atoi(buf);
that?
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++
Well, for fairly small files you can store them in a BLOB field in MySQL.
How about FMOD or something...
Also, MySQL is easy. Anyone can learn it, so just read a few tutorials.
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.
try putting global gold
as the first statement in any function that uses the variable 'gold'
also, you need to set length
, use strlen() for that.
The beep is due to an ASCII character, consoles read it as a beep.
I dunno how you can stop it, though.