954,483 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help with char statement

i have jut started learning cpp need help :

is their any way i can make a char statement conatining spaces too.
if yes plz tell me.
:rolleyes:

cpp noob
Newbie Poster
15 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

i got tc.exe

cpp noob
Newbie Poster
15 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 
is their any way i can make a char statement conatining spaces too.

What question are you trying to ask? The best I can manage is, "How can a read a line of text containing whitespace from the user?" If so, my next question would be, C or C++?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

I think s/he is trying to declare a variable "char" to values seperated by spaces. If so, you can simply do this:

char a[] = "Blue Moon";

Just replace "a" with the variable you want to use, and replace the words in quotation marks with your own statement. Hope this helps.

cscotty
Newbie Poster
12 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

i accually need help wwith this programm
here i want help so that any amount of words can be filled in the address

# include <iostream.h>
# include <conio.h>

void main()
{
	clrscr();
	char address[60];

	cout<<"Enter your address";
	cin>>address;
	cout<<"Your address is "<<address;
	getch();

}


<< moderator edit: added code tags : [code][/code] >>

cpp noob
Newbie Poster
15 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

Look up getline -- cin is whitespace delimited.

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

im relly a noob i dont know anything i just started learning c++
can u help me by editing my above program .

cpp noob
Newbie Poster
15 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

I edited your code, good for tc only...

# include <iostream.h>
# include <conio.h>

void main()
{
clrscr();
char address[60];

cout<<"Enter your address";
cin.getline(address,60,'\n');
cout<<"Your address is "<<address;
getch();

}
Asif_NSU
Posting Whiz
353 posts since Apr 2004
Reputation Points: 113
Solved Threads: 3
 

simple examlpe of getline:

char input[55];
    cin.getline(input,55);
zyruz
Junior Poster in Training
60 posts since Jun 2005
Reputation Points: 10
Solved Threads: 5
 

its showing a error

unable to open file "c0s.obj"

wut does it mean :eek:

cpp noob
Newbie Poster
15 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

It's trying to tell you to replace your old ass compiler with something that conforms to the C++ standard. Let me guess, your operating system is Windows XP, right?

>unable to open file "c0s.obj"
Go to Options, Directories and make sure that you see something like this sitting around there: c:\\lib

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

THANK YOU Everyone for your suppeort
when i tried the same thing today it was not showing the error (hmmm.......)

THANKS:-)

cpp noob
Newbie Poster
15 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You