dospy 51 Junior Poster in Training

no offence taken, after all you don't know my dad so you can't be on-spot with your assuptions about him
he doesn't make shit up, he just makes statements base on logical connections and i know, (i tell him all the time, but oh well) he is often wrong because he doesn't know all the implications of the underlying processes which can often distort the outcome of the bigger picture, but bear with me he is not ignorant, just outran by technology(but what can we expect from and soon to be old man?)

it's not ignorance, it's purely his way of surfing through this world.
anyway this is going offtopic, thx for the reply. see you safe

dospy 51 Junior Poster in Training

well my dad usually bases his statements on reason on deductions among with common knowledge of the subject(basically assumptions, but i have to say he is usually right in his statements); anyway, he based his affirmation on the fact that he used to work with magnetic bands as he was a DJ (in his youth :D) and he also asserts that magnetic bands have the same data stocation method as flash drives(which is false, altho both work with magnetic/electric fields)

dospy 51 Junior Poster in Training

first of all, thx for fast reply!
the point my dad was trying to make is that CDs are better for storing music and videos since they can be kept safer(information intact) whereas flash drives lose information due to magnetic processes that occure inside and there is no way to prevent that resulting in the degradation of the quality of the audio/video(ofc, the changes are nearly insesizable to us humans, but the point is that they exist and software will take care of handling the 'distorted' data)
maybe i haven't been clear from the start, but what concerns me is not which of the two types of data storers are better, but rather is the data likely to get damaged in a short period of time(3-4 months since writing let's say) on a flash drive?

Ps: anyway, to me, cd and dvds are rather useless now as i can't find a single problem to be solved by them and not memory sticks so.. just saying.

dospy 51 Junior Poster in Training

i've recently engaged in an argument with my dad about CDs and DVDs vs memory sticks and i basically stated that since nowadays it is common for almost everyone to have at least a 16GB stick, CDs and DVDs are basically becoming useless/non-convenient. he countered me stating that CDs have a higher quality for the stored memory compared to flash drives(meanning the processes needed to store/write data on it are pure mechanically, not involving any magnetic/electric processes as sticks do => the data on CDs is much more less likely to get distorted/destroyed) which makes CDs better for storing quality audio/video

now, my question is: is that true? flash drives are (very)prone to have information errors because of physical processes? and if so, how are these errors corrected?
i don't fully the grasp the conceps involving data writing on flash drives(i have the basic idea), hence i don't understand the implications that this process has.

EDIT: now i realize i posted this in the wrong section(facepalm); i am sorry for that, some admin please move it to the coresponding section.
thx for understanding

dospy 51 Junior Poster in Training

it turns out that i had to allocate the memory first(lol i dono how i omited that) and that's why i was getting a memory coruption; and about the default values, i managed my way around it using default parameters:

CMsgPacket::CMsgPacket(CHAT_COLOR _Color, CHAT_TYPE _ChatType, char* _Message, char* _To = "ALLUSERS", char* _From = "SYSTEM");

CMsgPacket::CMsgPacket(CHAT_COLOR _Color, CHAT_TYPE _ChatType, char* _Message, char* _To, char* _From)
{
    Msg_Len = strlen(_Message);
    m_Msg = new char[Msg_Len];
    strcpy(m_Msg, _Message);

    To_Len = strlen(_To);
    m_To = new char[To_Len];
    strcpy(m_To, _To);

    From_Len = strlen(_From);
    m_From = new char[From_Len];
    strcpy(m_From, _From);

    Color = _Color;
    ChatType = _ChatType;
}

this solved the problem

dospy 51 Junior Poster in Training

firstly, thx for the reply.
secondly, To, From and Message are proerties declared with the

 __declspec(property(put = SetFrom, get = GetFrom)) char* From;

syntax and they are used the same way as they are used in C#:

From = stuff;   // same as SetFrom(stuff);
stuff = From;   // same as stuff = GetFrom( );

now, about the

char msg[] = "A message"; // This is a temp variable that will be
                          // destroyed when goes out of scope

i read somewhere that the string constats are available through the whole runtime of the application as they are embded in the executable itself and the compiler just calls the address location, thus not going out of scope, but maybe i didn't understand corectly.
anyway, how should a correct implementation of the constructor look like, as it doesn't quite work with strcpy(From, "somestuff); either..., it gives me a memory violation when trying to write.
i was thinking of switching to std::string to get loose from all this char* crap and reimplement the class, but how would it be possible to use char* for this?, i am curious

edit:
this class was used like this

CMsgPacket *msg = new CMsgPacket( );
msg->To = "name";
msg->From = "from";
msg->Message = "some message";
msg->Color = CHAT_COLOR_WHITE;
msg->Type = CHAT_TYPE_SYSTEM;
Client->Send(msg);

and i want to reduce this to one single line as it is ugly and i have to send messages often so …

dospy 51 Junior Poster in Training

i want to construct a Message class which encapsulates and handles data for sending over a network; i want to acheive something like this:

Client->Send(new CMsgPacket("Some Message", CHAT_COLOR_WHITE, CHAT_TYPE_SERVICE));
// send function deletes the data after processing it
// this is the CMsgPacket class

class CMsgPacket
{
private:
    int Msg_Len, To_Len, From_Len;
    char* m_Msg, *m_To, *m_From;
    bool new_Msg, new_To, new_From;
public:
    CHAT_TYPE ChatType;
    DWORD Color;
    DWORD SenderUID;

    char* GetMessage( );
    void SetMessage(char* value);
    __declspec(property(put = SetMessage, get = GetMessage)) char* Message;
    char* GetTo( );
    void SetTo(char* value);
    __declspec(property(put = SetTo, get = GetTo)) char* To;
    char* GetFrom( );
    void SetFrom(char* value);
    __declspec(property(put = SetFrom, get = GetFrom)) char* From;

    CMsgPacket( );
    CMsgPacket::CMsgPacket(char* _Message, CHAT_COLOR _Color, CHAT_TYPE _ChatType);
};






char* CMsgPacket::GetMessage( ) { return m_Msg; }
void CMsgPacket::SetMessage(char* value) 
{ 
    if(new_Msg)
    {
        delete[] m_Msg;
        new_Msg = false;
    }
    m_Msg = value; 
    Msg_Len = strlen(value); 
}
//
char* CMsgPacket::GetTo( ) { return m_To; }
void CMsgPacket::SetTo(char* value) 
{ 
    if(new_To)
    {
        delete[] m_To;
        new_To = false;
    }
    m_To = value; 
    To_Len = strlen(m_To); 
}
//
char* CMsgPacket::GetFrom( ) { return m_From; }
void CMsgPacket::SetFrom(char* value) 
{ 
    if(new_From)
    {
        delete[] m_From;
        new_From = false;
    }
    m_From = value; 
    From_Len = strlen(m_From); 
}
//
//
// Size Function
WORD CMsgPacket::Size( )
{
    return 32 + From_Len + To_Len + Msg_Len;
}
CMsgPacket::CMsgPacket( )
{
    m_To = m_From = m_Msg = NULL;
    To_Len = From_Len = Msg_Len = 0;
    new_From = new_To = new_Msg = false;
    Color = SenderUID = 0;
    ChatType = CHAT_TYPE_NONE;
} …
dospy 51 Junior Poster in Training

nevermind i find a site with a full tutorial how to make a config file parser file. here is the source in case anybody wonders/wants it:
Click Here

dospy 51 Junior Poster in Training

the basic idea is that i have a config file where i need to take entries in different formats(the key is always a string and the value could be any type: int, float, string etc) from and the file has the following style:

firstentry 1.5
secondentry 35
thirdentry somestring

and i have this code to try to read int values from the entries but it gives me a lot of errors:

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include <Windows.h>

using namespace std;

map<string, stringstream> entries;

int ReadInt(const string& key)
{
    int value;
    stringstream SS;
    for(auto i = entries.begin( ); i != entries.end( ); i++)
    {
        if(i->first == key)
        {
            SS = i->second;
            SS >> value;
            return value;
        }
    }
//  throw "Value not found";
    return 0;
}

int main( )
{
    ifstream file("abc.txt");
    string line, key;

    while(getline(file, line))
    {
        cout << "reading line..." << endl;
        stringstream SS(line);
        SS >> key;
        entries[key] = SS;
    }

    int x = ReadInt("firstentry");
    int y = ReadInt("secondentry");

    cout << x << " " << y << endl;

    system("pause");
    return 0;
}

errors:

1>------ Build started: Project: abc, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\istream(860): error C2249: 'std::basic_ios<_Elem,_Traits>::operator =' : no accessible path to private member declared in virtual base 'std::basic_ios<_Elem,_Traits>'
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char>
1>          ]
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\ios(177) : see declaration of 'std::basic_ios<_Elem,_Traits>::operator ='
1>          with
1>          [
1>              _Elem=char,
1>              _Traits=std::char_traits<char> …
dospy 51 Junior Poster in Training

i tried that already with no result, actually, the installation finished successfuly, but when trying to build with qt creator, it told me that i need to set a compiler and when i chose compiler from msvc it told me that "this compiler cannot procuduce code for this version of QT" or something like that. So.... yea

dospy 51 Junior Poster in Training

because that could be triggered by others application which modify the clipboard.
i cannot help you OP, sorry

dospy 51 Junior Poster in Training

i honestly think he means "a way to spoof IP" and probably by modifying the packet content to replace his true IP with a fake one, which, as far as i know, is not 'reliable' since you will be able to spoof the (sent) packets' IP, but you won't be able to recieve anymore packets since th other end is sending them to another address(i could be wrong though).
and i think he wants to spoof ip to be able to connect to servers which he was banned from?

dospy 51 Junior Poster in Training

first of all, sorry if this thread is in the wrong section, but i think this is the most appropiate one
i need clear instructions for installing AND configuring QT for my machine(i am running windows 7 on 64bit)
i don't want other reference links unless they perfectly suit my situation as i spent over 8 hours wondering around the net and trying to get it done myself using indication from spread sources
i want to use the QT creator as the IDE for creating GUI application in C++. the thing is i don't want to install extra compilers and i want it configured with my Microsoft Visual Studio 2012 compiler for c++.
so, can some1 make a step by step guide for installing QT and configuring it to run using MSVC 2012?
thx in advance

dospy 51 Junior Poster in Training

the problem is that the packets don't arrive to packet sniffers because they are discarded right away

dospy 51 Junior Poster in Training

i think he wants to know that if there is a way to output variables with a loop statement which contains only one instruction whithin the brackets like this:

int age = 32;
char name[50] = "Pickatchu";
double height = "1.65";

for(int i = 0; i < 3; i++)
{
    cout << ..... << endl;
}

something instead of "....." to output:

32
Pickatchu
1.65

the simple answer is no
there is altho a way aroud this but is too unconvinient(overhead)

dospy 51 Junior Poster in Training

i'm learning about networking on a site and there says there are 3 types of sending data:
unicast, multicast and broadcast
in the unicast case the IP layer encapsulates the IP destination(let's say "derp"). the interesting fact i've read about the unicast is that all machines within the same network will recieve the packet that is supposed to arrive at derp, but only derp will 'accept' the packet as the rest of the machines will drop it seeing the destination IP doesn't match with its IP.
so, i suppose kernel does check the ip matching which means it also drops the packet if it doesn't match.
what i'm interested in: "is it possible to catch the packets denied by kernel?" if yes, how?

dospy 51 Junior Poster in Training

thx for responses guys, but never mind it, i'll try to find an easier solution, because it seems that the chip i am trying to program doesn't support advance C++, not ever libraries, just native C and the predefined functions used to manipulate the circuit

dospy 51 Junior Poster in Training

t to do something like

void f1(int a[][])
{//do smth
}
//and call the function like this
F1({{1,0},{2,5}});
dospy 51 Junior Poster in Training

instead of

void student_grades(student_grades&paste){
name=name.paste;
Id=Id.paste;

try

void student_grades(student_grades&paste){
name=paste.name;
Id=paste.Id;

also, you'd better follow some tutorials of how to write clean code and improve your writing style because you code layout is horrible(no offense)

dospy 51 Junior Poster in Training

i think he means that he can write an web page using C++
for ex. a console - server that imitates the behavior of an HTML written website;
it is possible, tho a lot more effort to write it

dospy 51 Junior Poster in Training

first post your code, then we will help
none will do all your work for you
read the forum rules please

dospy 51 Junior Poster in Training

you must provide CLEAR details if you want people to help you, what exactly is suppose your code to do?

sergent commented: . +7
dospy 51 Junior Poster in Training

or you can write the namespace contents and than wrap it all in the namespace u wanted

sergent commented: good idea +6
dospy 51 Junior Poster in Training

i looked through your site, it seems you are not lying but i don't see why someone who wants to develop a big project would use that, but still, good job..

dospy 51 Junior Poster in Training

ok so, i followed the steps in the guide and didn't manage to succeed
i hate when people build tutorials in witch they give instructions like the reader already does know how to do it
i got so mad that i don't want to hear about boost anymore for a while, actually i don't see the rush, i still have to learn sockets first so screw boost::threads for now.

dospy 51 Junior Poster in Training

thank you

i think she meant "Why are you posting it here?" :D, i have the same question in mind, also i'd like to see your code converter(but i have big doubts you are not lying)

dospy 51 Junior Poster in Training

if this is your homework it means that you should know to do it, it's not our fault that you didn't learn when you have to.
we can't do that for you, we only can guide you to the right direction, not build the path for you

tkud commented: Well said +5
dospy 51 Junior Poster in Training

you don't have to buy a book, search on google the book name followed by PDF and you'll find pdf file(witch you don't have to download if you don't want) where you can learn from
ex:
"thinking in c++ pdf" - >http://www.lib.ru.ac.th/download/e-books/TIC2Vone.pdf

Azmah commented: Nice source +3
dospy 51 Junior Poster in Training

thx for reply, i searched on they'r site but couldn't find anything related to building them, it seems that i didn't search well enough, still, i'll be keeping the thread open until i build them, if any error occurs i'll post again

dospy 51 Junior Poster in Training

i've downloaded the last version of boost(1_47_0) but i don't know how to build it, i tried to find a tutorial on google but that didn't help much because it was for a very old version and some thing changed.
anyway, my compiler does have minimal support for C++0x, will boost work on it(MSVC 2010 express).
and also i'll be thankful if you could tell me STEP BY STEP(as for idiots) how to build the libraries

thx in advance

dospy 51 Junior Poster in Training

none will do your homework unless you at least try and tell us what you don't know, if you know nothing about how to do it, too bad, go and learn

dospy 51 Junior Poster in Training

i still prefer iostream over stdio.h because iostream is designed for all basic types of input and output, not only for console

dospy 51 Junior Poster in Training

as Narue stated, you have to put all the default parameters at the end of the function declaration
as this

TwoDayPackage(const string&,const string&,const string&,const string&,
              const string&,const string&,const string&,const string&,
              double=0.0,double=0.0,double=0.0,int=0,int=0);

and for the too many arguments problem, you could use vectors..
ex:

TwoDayPackage(const vector<string>& strVector, const vector<double>& doubleVector, const vector<int>& intVector);

and you could use a define to trick the compiler to let you call it with one argument(treat rest like default)

#define TDPackage(x) TwoDayPackage(x, vector<double>( ), vector<int>( ))

edit: i've seen that the string parameters are related to each other, in this case you could create a special storage class and make it the function parameter like this

class StrStorage
{
public:
string m_Data1;
string m_Data2;
// ... etc
StrStorage(const string& nData1, const string& nData2) : m_Data1(nData1), m_Data2(nData2) { }
~StrStorage( );
}

// and than call the function this way
StrStorage strings("string 1", "string 2");
TDPackage(strings); // note you will have to modify the function to accept the StrStorage instead of a vector<string>
// or alternatively
TDPackage(StrStorage("string1", "string2"));// i won't use this one because you have to pass a lot of strings and that's waht you are trying to avoid
dospy 51 Junior Poster in Training

>> Basically, because you didn't call it properly, you've unintentionally overloaded the function, but you don't have a definition/implementation of the overloaded version.
i think you'r wrong about that, you cant declare a function as this

b.getLeafCount();

you must use :: operator to tell the compiler that it belongs to a class, not the '.' operator

dospy 51 Junior Poster in Training
ConstructorX(string first):firstName(first)

basically, when you pass an argument to this function, your program will:
1)create an string object(first)
2)copy contents from the argument passed to the object
3)firstName will be initialized with the object(note: another copy activity)

now, if you use this way

ConstructorX(string &first):firstName(first)

your program will:
1)pass the argument directly to the function(skipping the overhead of creating and then copying another object)
2)firstName will be initialized with the object(note: another copy activity)

note that here, it passes the argument directly so it gives you the possibility to change it's value/contents in the function; for ex

#include <iostream>
void AddOne(int x)
{
    // x is a local variable
    x++; // increments the copy witch won't help us at all
    // x goes out of scope, the argument passed remains unchanged
}
void AddOne2(int &x)
{
    x++; // x is a reference to the argument, so, the argument increments
}

int main( )
{
    int nVar = 1;
    AddOne(nVar); // nVar value remains 1
    std::cout << nVar << std::endl; // prints 1;

    AddOne2(nVar); // nVar value increments to 2
    std::cout << nVar << std::endl; // prints 2;

    return 0;
}

if you still want your function to get the argument directly excluding the possibility to be changed just declare it as a constant reference

void AddOne2(const int &x)
{
    x++; // error, x is constant
}

so, your function will be faster if you use const references

const …
dospy 51 Junior Poster in Training

>> Your basic console mode "Hello, World!" program comes in around 6 K using stdio.h and printf and anywhere between 250 K - 500 K using iostream and std::cout.

what do you mean by K?

about the rest posts, i see no reason to change from using char to wchar_t, anyway, if someone wants support for other alphabets it means that he is dealing with a big/complex project(witch involve creating a GUI), so neither in such a project i see an advantage

dospy 51 Junior Poster in Training

i've seen many programs using printf( ) for outputing(probable ported from C) but anyway, is there any difference between printf and cout?
also i've seen many functions(expecially in windows.h) using w_char*(wide char string) as arguments or return value(and it bugs me because it makes difficult to use with strings)
what's the difference, why they needed to make 2 types of strings, char string and w_char string?

dospy 51 Junior Poster in Training

thx for the fast answer :)

dospy 51 Junior Poster in Training

i have this question in mind since i first found out that you can declare and array like this

<type>* nArray

how does the compiler how much storage to allocate?
i've heard that it doesn't allocate any storage, it just points to some address and when you use index operator like this

nArray[n]

it just returns the object n addresses far from the pointer.
if that's so, how does the compiler handle new(exact type of the array) variables declaration without risking an overriding of the memory:

int* nArray; // lets assume that it points to address 0x00000000
int nInt; // has the address of 0x00000004?
// that would mean like nArray + 1 points to nInt witch doesn't seem to be right
dospy 51 Junior Poster in Training

thx for the tutorial.

dospy 51 Junior Poster in Training

Yes I think Visual studio 2010 has it

not really, MSVC 2010 has little support for c++ 0x
for example the syntax

for(int& x : <some vector/array/pointer>)

is not valid
same goes for 'constexpr' and many more..

for more vizit
http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx

dospy 51 Junior Poster in Training

describe your problem in more detail, anyway if i got it right, you can't do what you want cuz the compiler won't let you return a reference to temporary object(declared in the function body)

ps: your code isn't even valid so i can't tell exactlty what you really want..

dospy 51 Junior Poster in Training

i am planing to learn sockets, threads, maybe some librarys for interfaces
if i have to read a book for every of this it'll take me years to learn.. i need something more quick

dospy 51 Junior Poster in Training

i really need a GOOD socket tutorial, i've followed some of them from google but they aren't complete, i know that socket programming is forked into many categories, basically i am interested blocking & non blocking sockets, synchronous & asynchronous sockets(used with select() and FD_ISSET macro etc)

PS: i know the pattern on how socket works but i can't seem to get it programmed wright, i tried 3 times to make a direct client-server model app(just connection, not exchange of data) and it didn't turn out so well..

dospy 51 Junior Poster in Training

i am not sure i understood what you want, if i got it right, the thing goes more complicated

this way you find ALL matches in the set

int matches;
for(j = 0; B[j] <= SS; ++j)
{
    matches = 0;    
    for(int k = j; k <= SS; k++)
    {
        if(B[j] == B[k])
            matches++;
    }
    if(matches > 1)
        cout << matches << " entries of the number " << B[j] << "in the set" << endl;

    matches = 0;
}
/*
note that this will output the pairs of numbers more than one time.
for example we have the set: 1, 10, 10, 10
when the main loop arrives at the first 10 it'll output
'3 entries of the number 10 in the set'
and than goes to the second one, so it'll print again and again...

if you want only one time you'll have to implement a function for erasing all elements equal to the parameter from the array
something like this:

void EraseEl(int a[], int el, unsigned int size)
{
// code here for erasing all elements equal with 'et' from the vector...
}
*/

from here you can adapt it to your code

dospy 51 Junior Poster in Training

>> I think what you are asking is how to reverse engineer the protocol.
yea that was it, sorry, my English kinda sucks...
thx for your answer

dospy 51 Junior Poster in Training

when you want to decript a program's protocol how do you do it?
you use an packet listener(eg. WireShark) and try to figure out what each packet means?
is this the only solution? cuz it seems to me like a lot of hard work, is there anything to make this thing easier?

dospy 51 Junior Poster in Training

the code looks fine to me, what exactly is the problem?

edit: noone will do the functions for you if you don't at least try to...
we are here to help people, and by giving them the full code we don't help them at all, they need to understand first

dospy 51 Junior Poster in Training

font has nothing to do whit ofstream, ofstream is used only for writing to a file
the text editor that you are using has features that change the font, but that doesn't have anything to do with what the file contains

dospy 51 Junior Poster in Training

noone will help you to do such a program because your purpose of using it is just stupid.
it's like you would want to keep yourself tied when you know how to escape