FireNet 64 Posting Whiz in Training

True enough,about certain char being translated in the text mode.But let me remind that file<<"abc123" is a string.Try doing file<<"abc"<<123<<(char)123;

See what happens, one forgets and assumes a bit somethimes.

If you open an ofstream object with a file name, and write output to it, then call open() on the same file stream without closing it, there will be no errors. The call to open() will close the file you were writing to and just open another file. Similarly:

Try doing that with the fstream object.Also if an fstream object is declared in the global scope and it's not closed when you run the program again some access errors might be shown. A lot of my friends had this problem when they did their projects.Never declare anything global unless it's necessary.

This may not be true on diffrent compilers (or even the same one's diffrent versions).That could have happened due to a lot of reasons.But it a good practice to alway close a file handle before you exit .I just said something which might possibly happen, :).

I love the fstreams too.Thanks so much Jubulani.

FireNet 64 Posting Whiz in Training

The Brain - the one and only

FireNet 64 Posting Whiz in Training

ah it's simple, just do for(int i=0; i<.......

A for loop has it's own scope so you have to declare the i again.

FireNet 64 Posting Whiz in Training

const is short for constant.An constant must be initialised when it is declared and it cannot be changed.

In a class you cannot declare a member as datatype data_var = some_value since it's against standards and each object of that class has a sperate space in mem to store all it's members.

when a member is declared as static, all the objects of the class share this value and you can assign a value as static datatype data_var = some_value as you cannot do that in the constuctor as when an object is initialised this value will get overwriten.So we are allowed to do it within the class.

Helps?

p.s: look up on constructors

FireNet 64 Posting Whiz in Training

True alc6379, common shabna, we dont get paid for doing this, we are in this to help each other.Chainsaw is a jolly good guy, but if someone wants to take things up a bit, you will find yourself being kicked around.

Btw, check your other post, Stack Overflow has given some very good links which I recommend you read and remmember.
http://www.daniweb.com/techtalkforums/thread10188.html

FireNet 64 Posting Whiz in Training

A little update.My site URL is now:
http://xlock.hostcubix.com/

FireNet 64 Posting Whiz in Training
FireNet 64 Posting Whiz in Training

Borland free C++ compiler i.e version 5.x does not come with and editor or and IDE.
But I heard they did release version 3.x compleately free along with the IDE.Go get that one if you can.

http://www.borland.com/

FireNet 64 Posting Whiz in Training

You will need to learn more C++ if you dont know what you are supposed to type.

To make objects move is quite simple.Just add to their X,Y coordinates and draw them to the screen.Post your code and we will check it out and will help.

I would rather that you used a C++ programming book to learn C++ if you are not fimiliar with c++ concepts like classes

FireNet 64 Posting Whiz in Training

True enough, but Kids out there only want it for fun,revenge, for an example.

Anyway this kind of stuff can be best dicussed in fourms dedicated to internet security.

It's better we dont discuss that stuff here in a general C++ fourm.Virus are dangerous if the guy who copies the code does not know what the heck it does.No need to play with acid carried in a tube with both sides open.

Best Keep it closed. :rolleyes: :mrgreen:

FireNet 64 Posting Whiz in Training

Use conio.h

TextColor(int)
BackgroundColor(int)

values range from 0-15, with 0 being black and 15 white.Open conio.h and you will find the entire list of colors there. :).Have fun

FireNet 64 Posting Whiz in Training

That means the compiler could not find the object "resultarray" which was declared as an extern.Extern says to the compiler that a variable has been declared somewhere else but in this case the compiler could not find it.

FireNet 64 Posting Whiz in Training

Here's a link:Check it and see, ask if in doubt

http://www.daniweb.com/techtalkforums/thread9878.html

FireNet 64 Posting Whiz in Training

Yea, better use fstreams they are much better and easier to use.Here's a link:
http://www.daniweb.com/techtalkforums/thread6542.html

Try posting some of your code too.We might be able to help you better then.

FireNet 64 Posting Whiz in Training

conio.h

It has a lot funtions for console input/output.Take a look at it.

TextColor(RED);
TextBackground(BLUE);

The color values range from 0-15 with 0 being black and 15 being white

warning,i am not too sure of the funtion names,been a while since i used this, though i used it almost everywhere, man time flies

FireNet 64 Posting Whiz in Training

Try to understand the concept of pointers rather.It's simple actually.A pointer points to the address in memory of a variable.That way if you change one, the changes can be seen at all places.Multiple pointer can point to a variable.

A var can be tought of as a TV and the pointer a Remote Control.Change the channel anywhere,the result is on the TV.And a TV can have multiple remotes ;)

Look below:

&val means address of the variable var
*p (if is a pointer (int *p; )) means value at address pointed at by p.Changes this will change the variable it points to.

int val = 1;
p=&val;
val+=10

cout<<val<<" *p="<<*p; //output is the same for both
(*p) += 4; //changes the value of val
cout<<val<<" *p="<<*p; //output is the same for both

The outputs are:
11 11
15 15

*(p++) increses the address to which it points to by the pointers datatype size.
*(p)++ increses the val at the address pointed by p by 1.

Understand the pointer concept ;) ?

FireNet 64 Posting Whiz in Training

&val means address of the varialble var
*p (if is a pointer (int *p;)) means value at address pointed at by p.Changes this will change the variable it points to.

int val = 1;
p=&val;
val+=10

cout<<val<<" *p="<<*p; //output is the same for both
(*p) += 4; //changes the value of val
cout<<val<<" *p="<<*p; //output is the same for both

The outputs are:
11 11
15 15

FireNet 64 Posting Whiz in Training
//Warning,written by hand.Mistakes are possible

void pass(char *s,int len,char mask='*')
{
     int loc = 0;
     char p;
     int x = getx();
     int y = gety();

    do
      {
          p = getch();
          if(p == '\r')           // \r = enter
          {
                s[loc] = 0;
                break;
          }
          else if(p == '\b')   // \b means backspace
          {
               if(loc>0)
               {
                       s[loc]=0;
                       loc--
                       gotoxy(x-1,y);
                       cout<<" ";
                       gotoxy(--x,y);
               }
          }
          else
          {
                s[loc++] = p;
                 x++;
                cout<<m;
          }

     }
    while(true);
}
FireNet 64 Posting Whiz in Training

Can someone please explain to me the difference between ++i and i++ when written as part of an expression (i.e. within loops and if statements) ? Thanks :)

Could I suggest a book?: C++ Primer 3rd Edition

Covers tiny stuff like performance details and the new C++ standard very well,bit advanced but very good if you want details.

Postfix(p++) and Perfix(++p).

Rules
p++ - First use value then increment.
++p - First increment then use value.

If you still dint understand after all the stuff the other guys gave.Then check this out.

You are mad at a guy, he shouts at you,making you madder.With p++ you shout at the guy then slap him and with ++p you slap him first, then shout at him.

The end result is that on the first case he would have got a piece of your mind before getting the physical part for what ever he did, and the other way around with the second.
Which method you want to use depends on the situation and your choice.

(Hint: p++, if you plan on running)

;),no offense anyone.

Also,val++ (real c++ here ok) is what is commonly used by many programmers.

As far as loops go it depends on which type of loop you re going to use like
for(), while() , and do while() ,where it's declared and where the expression is placed.Just apply the rules and you will have …

FireNet 64 Posting Whiz in Training

An array is declared:
datatype array_name[int_size];

Eg. int vals[10];

int *p = vals;

Then p[0] = vals[0] and p[1] = vals[1] and so on.
Also you can access the vals by *(p+i) instead of the [], and the expression is read as the value at the address of p+i.

An array var is also a pointer so you dont need a & in front of it when you assign it to another pointer.But if you want to just point to a single int for example:

int *p = &val; //means p = address of val

and you can access the value a the address pointed to by p usinf another_int = *p ;

---Helps???

FireNet 64 Posting Whiz in Training

Dont Know any as per se.

Also it's not too hard at all convertion between UNIX and WIN32.Only a few funtions and some funtion returns are all that differ.You should have no trouble after you have looked at a few pages

Links:
Beej's Guide to Networking Cool and detailed unix socket programming

Goto http://www.google.com/ and search.

FireNet 64 Posting Whiz in Training

You can use text edits for doing that but it might be a bit boring having to make use of so many #define s.

Then again try google for source of some sales management software and check it out.

Also look into MFC, it provides a lot of things to make using the windows API simple, as long as you are not going for any graphics/cpu intensive stuff.

FireNet 64 Posting Whiz in Training

If Calculus is fun,C++ is close to haven.

Really it's how you take your stand to it,love it and it will love you (if you dont use VC++ ;) ).

Hate it,and it will kill you,almost.

FireNet 64 Posting Whiz in Training

Ok,meabed why dont you write a YourDoom virus,just kidding ;)

The Hello world program might have been the most important C++ for must.My first one said "This is COOL, I will conquer it".And I can say I am well on my way. ;).

Also ICEBAZOOKA.cpp was fun too.Start your comp,a small guy appears,takes out a tiny bazooka,tries to lift it,cant fall,you laugh,he fires,00000000wwwwww a small bullet which grows larger comes to you,hit the screen,bang,all the icons & screens look frozen, touch your mouse and you will find everything has frozen.Look for the little creep,he's gone.

FireNet 64 Posting Whiz in Training

Well,I have done the second part but still doing the code examples.About making it easier,I dont really know,but just simply follow the stuff like the bios calls,like you followed cout<<.Later when you progress you will learn about them.No use confusing yourself now.

Then again maybe I might do a section covering bios calls and stuff very lightly and drop that assembler section.

Hey I am not a know it all,but learned it from here and there, and still learning.

(P.S:I forgot a small bit in the code, the byte datatype is an unsigned char)
(just add a typedef unsigned char byte;)

FireNet 64 Posting Whiz in Training

Hurry up?,where ??

To get plenty of that stuff got to www.google.com
or search the C++ fourm and you will find one.

FireNet 64 Posting Whiz in Training

Try linking with winsock.lib

FireNet 64 Posting Whiz in Training

FrozenICE.cpp to BurningHell.cpp

Hey,what else did you expect anyway.Cool depend on you.;)

FireNet 64 Posting Whiz in Training

Yea,using #include <iostream> is now the latest standard.

namespaces are something like a sealed off area of code,out side which you can use the same names with out conflicting with the name in the namespace scope.

You can also access namespace vars like namespace::std, std::cout

Have fun,ALSO learn to use the Standard Template Library (STL)

FireNet 64 Posting Whiz in Training

That depends on a lot of things like the OS ,your compiler etc.

There are a lot of libraries available which you can use on multiple OSs which provide raw packet access for TCP/IP,UDP,ethernet cards etc.

Look to http://www.google.com/ for info,downloads

Best of luck,you got a lot of reading to do.

(Btw,if you use windows look for WinPcap )
http://winpcap.polito.it/

FireNet 64 Posting Whiz in Training

Conversion is a complicated thing,when it comes to diffrent compilers or OSs.

Mainly it's the header files,slight variations in the standard structures,diffrent funtion names etc. which are a problem.

I run into this quite often,but it's not too hard.The only thing is that use should understand what the code is doing,know your compiler well.

BCB (borland c++ builder,right?).I have never really used it.Sorry about that.

Anyway what seems to be the general problem,errors ?

FireNet 64 Posting Whiz in Training

Quite simple really,just open word.txt with ios::app (append) added to the options when opening the file.That will automaticaly put the file pointer to the end of the file and you can just write to it normally.

Another way is to open the file and use filehandle.seekp(0,ios::end); to move the pointer to the end of the file and then write the output you want to the file and it will still be at the end.

Checks the tut for the list of options,I covered them there.

Btw,then close the file when you exit or are finished with using it.There you go a new word was added to the file.

FireNet 64 Posting Whiz in Training

Use :

char charface = 1;

cout<<charface;// or even printf()

That will output the smilie face to the screen,the rest is easy.

FireNet 64 Posting Whiz in Training

Gee,if you want just an overall stuff about things you dont know then try http://www.google.com
That will give you lots of good stuff,as I always say enough to drown in.


P.S If you want a tut on winsock servers try the tut fourm here at daniweb.

FireNet 64 Posting Whiz in Training
FireNet 64 Posting Whiz in Training

Ok,that can be done quite easily if you know your file handling and a little bit of char manipulation.

If you want a tutorial on file handling then here is a link.
http://www.daniweb.com/techtalkforums/thread6542.html

Now here is an idea on how to do it.

1.First open the jumbled file
2.Open an output file
3.Read a line from the jumbled file

Now let the line be like:12 0000000XX0000XXXXXX

4.Get the line no (i.e 12) by copying the letter for the read line till you reach a space
5.If the number is the current line (i.e 1) then write to output file
6.Do this till all the lines are done and keep repeating the jumbled file reading.


Ok simple eh,but it's not too good or efficient but should do the job.Also to convert a char array which holds a num like "2324" into a int use atoi() (#include stdlib.h)

char char_num[] = "sdfsd";
int x = atoi(char_num);

FireNet 64 Posting Whiz in Training

Good point too,the fourms are getting filled.Hey there's plenty of space in an ocean anyway.

FireNet 64 Posting Whiz in Training

Please reffer to your post about networking stuff for my answer.

http://www.daniweb.com/techtalkforums/thread8956.html

Hey,give details.There are a lot of message passing interfaces types related to various totally diffrent stuff........

FireNet 64 Posting Whiz in Training

Boy:I dont know why you are angry at me !!!!
Girl:If you dont know,I am not gona tell you, so do something about it...

.... yea right,something similar here eh?You aint giving any details buddy.

Ok as far as details go,give your compiler (name,version.. etc), compiler errors (copy paste), your target (what the prog has to do), source code (at least relevent parts).

This much will sure help the helpers help the helpi (any word like that,chaser and chasi ?,or what ever the spelling).

Ok ok,I will cool it,hey had nothing else to say anyway.

If anyone wants any useful help anywhere,give details of the problems or the help you get might be more trouble.Anyway the helpers will be shooting in the dark,with the gun behind their backs (or what ever way you want it,< p.s no nightvision possible ;) >)

[P.S: when compiling dont forget to link to winsock.lib]

FireNet 64 Posting Whiz in Training

True, even simple games are not something everyone can wip up ya know.

If you really want to make games,then you must know the lang you use quite well,also you should know some API like OpenGL or DirectX if you want to do GUI,window based games without going down to rasterization (drawing your on lines,polygons etc).Else you will want to learn the Windows GUI API.

Or you can go in for DOS console based games using Mode13h or ModeX.

So much for displaying wath you want.The rest of the stuff like internals of the game are up to you and your skill.If you think logically you can make games quite easilly.The best step is to first plan out everything before you actully start coding.

Belive me, and also start out with the simplest game you can think of.

http://www.gamedev.net/

FireNet 64 Posting Whiz in Training

#pragma is usally used to set compiler options within the source,like telling it to link to a static lib before compiling.That stuff usally need one to make a project but with an #pragma it's quite easy if you are in a hurry.

Oh,it's syntax is usually compiler specific.For example in Borland C++,to link to a lib :
#pragma comment (lib,"path to lib")

Look in your compiler's docs to get more specific info.

FireNet 64 Posting Whiz in Training

:D,Nice of you to thank those who help you out,but rather than post a new thread for that,you could try sending them a private message or even post at the theard in which they helped you out.It would be much better since here nobody would know what help was given.

(P.S: Give them a boost to their reputation, thums up & thums down).Glad you were able to solve your problem :D.

FireNet 64 Posting Whiz in Training

Quite Nice,Naveen

FireNet 64 Posting Whiz in Training

That's simple,lol

Just divide the year by 4 using modulus (%).

if(year % 4 == 0) cout<< "Yahoo a leap year";

FireNet 64 Posting Whiz in Training

Try the fstream tutorial here at Daniweb.You should find it useful.Covers a lot of stuff related to file i/o. :D
http://www.daniweb.com/techtalkforums/thread6542.html

Btw,you dont really have to store a number at line 10 to say it's line 10.Try this

//stuff needed here ;-)

while(!file.eof())
{
    file.getline(txt_buffer,80);
    no_of_line++;

    if(no_of_line == 10) 
    {
        cout<<txt_buffer;
        break;
    }
}

file.close();

Agreed it's a bit slow and takes too many readings,but it's a better way to read lines line to store within the file the line number.

There is a better way,using structs or classes which is discussed in the tutorial

FireNet 64 Posting Whiz in Training

Hello, my name is kerry and i just sign up .Well, my question is how do reverse a number input by user using recersive function.Thanks for the help.

You mean recursive funtion.The concept is quite simple.You take a number (to be reversed) and divide it by 10 and add the remainder to another number.As every loop goes by you multiply 10 to the other number and keep adding the remainders till you get 0.

Check this out

int n=12345,m=0;
cout<<"Orginal No:"<<n;
while(n>0)
{
    m *= 10;
    m += n%10;
    n /= 10;
}

cout<<"\nRevesed No:"<<m;
FireNet 64 Posting Whiz in Training

Post some of your code.We could help out then. :D

FireNet 64 Posting Whiz in Training

Oh common now,that's simple stuff.Try what you can and post your code here,we will help you out in your problem area.(No homework solving handed out :D)

FireNet 64 Posting Whiz in Training

http://www.google.com

Try there....... (we are not lingusists,yet)

FireNet 64 Posting Whiz in Training

Don't use const(ant) float.Try using a normal float :D.
Once a constant is initialised it's value cant be changed AND you have to initialise a constant ALWAYS.

const float num = 10;
const float num1 = num;

The above will work. :!: