Post your C/C++ Programs Here

Status
Not open for further replies.

Sykora

I see right through you.
Re: Post ur C/C++ Programs Here

You're right. getline is used with the C++ std::string while cin.getline() is used with char*. You should use std::string whenever possible, but if you're dealing with char* (for whichever reason), use cin.getline().
 

aditya.shevade

Console Junkie
Re: Post ur C/C++ Programs Here

What do you mean by declare feof?

Syntax of use if feof(file poniter name) and if you mean the key sequence for end of file then it is ctrl+z in windows/dos and ctrl+d in *nix OS.

EDIT :- the syntax of use is feof(file pointer name)
 
Last edited:

its me

Right off the assembly line
Re: Post ur C/C++ Programs Here

Hello



I need a program in C++ that convert numbers from Hexadecimal to Binary


thanks :p
 

nightcrawler

Broken In
Re: Post ur C/C++ Programs Here

its me said:
Hello



I need a program in C++ that convert numbers from Hexadecimal to Binary


thanks :p

1. Get Input from user in Hexadecimal format. The C scanf() with %x works in C. I am sure cin can directly take input in hexadecimal. BTW you have to preceed the input with a 0xNumber for example 0x1F for 31.

2. Once you have the number apply bit shifting logic or normal method of divide and mod. And get the binary number (that is if you wish to store it).

If on the other hand if you wish just to print it I think cout lets you do that like it lets you print in hex. Although I am not sure if it can print in binary.

Correct me if I am wrong guys.

Incidentally why would you want to convert a number from hex to binary ?
 

ilugd

Beware of the innocent
Re: Post ur C/C++ Programs Here

much simpler. One hx digit is 4 binary. Just create an array of 16 which matches each hexadecimal character to its binary equivalent and print it out. It is not puritan but gets the job done.
 

quan chi

mortal kombat
Re: Post ur C/C++ Programs Here

guys i have a problem please help.
well can anyone please give me a program on 'classes with other classses as member data'.with a bit of explanation.

for eg you can take a rectangle and point class.

actually there is a program for it but i am not able to get it properly
can anyone please explain it me.
here is the program.
Code:
class point
{private:
  int itsx;   //to hold the x and y co-ordinate
  int itsy;
public:
void setx(int x){itsx=x}
void sety(int y){itsy=y}
int getx()const{return itsx;}
int gety()const{return itsy;}
};

class rectangle
{private:

point itsupperleft;  /* from here i am not understanding.if these are of
point itsupperright;     type point then why the below its top bottom left etc 
point itslowerleft;         has been defined*/   
point itslowerright;

int itstop;
int itsleft;
int itsbottom;
int its right; 

public:
rectangle(int top,int left,int bottom,int right);
~rectangle(){}

*********the accessor functions defined here********

int getarea() const;

};

rectangle::rectangle(int top,etc etc.....)
{itstop=top;
itsleft=left;
etc etc.......;

itsupperleft.setx(left); /*why these declarations */
itsupperleft.sety(top);

itsupperright.setx(right);
itsupperright.sety(top);

etc etc.....;
}
int rectangle::getarea()const
{int width=its right-its left;        /*how they are calculating it
int height=its top-its bottom;        are they subtracting the two opposite
return(width*height);                    points*/

int main()
{body etc etc.......
}


i have pointed my doubts in the program only.
is there any other simpler way to write this program.or can anybody post any other simpler program.

i reffered sams publications jesse liberty and bradley jones book.pg no.165.

please help.
 

CadCrazy

in search of myself
Re: Post ur C/C++ Programs Here

Here is mine


#include<stdio.h>

void main()
{
int Money, GirlFriends;

while(Money!=0)
{
GirlFriends++;
Money--;
}
printf("Beggar");

getch();
}

:D
 

QwertyManiac

Commander in Chief
Re: Post ur C/C++ Programs Here

Some sites have the v3.0 in their abandonware list .. But Borland still has a page for it OUTSIDE the museum... I wouldn't know if its perfectly legal or not to distribute it now. But frankly, I cant stand that stupid IDE anymore. Its like staring at a BSOD for 5 hours only to build something equivalent of giving a BSOD in itself. Wonder why people don't move on ... :?
 

aditya.shevade

Console Junkie
Re: Post ur C/C++ Programs Here

Maybe because of the authors of books (indian) which emphasize on TC. Or maybe, like here in my case, my friends use it cause their classes have it. Or maybe because they have to use it in their colleges.

I hate it by the way.
 
Status
Not open for further replies.
Top Bottom