Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
how we enter the string of word then show the string (char)
Posted
Comments
ZurdoDev 13-Apr-12 15:49pm    
What does this mean? This is not clear in English.
Anderso0on 13-Apr-12 15:51pm    
i want do like this
input : "hello world"
output :
h
e
l
l
o
w
o
r
l
d
[no name] 13-Apr-12 19:26pm    
Have you tried anything?
Aescleal 14-Apr-12 5:17am    
This looks a bit homeworky to me, as it's not the sort of thing most jobbing coders would have trouble with or even have to do. Despite something that's a bit disgusting and cheesy below perhaps give it a try then more experienced people will be willing to give it a try.

If it's actually for a job you're doing then I'd love to know what application area you're using this for, it boggles my mind and I really like finding out new things.

Cheers,

Ash

Sample code,
C++
#include "stdafx.h"
#include "iostream"
using namespace std;


int main ()
{
	char str[10];
	cout<<"Enter string ";
	cin>>str;//get the string from keyboard
	cout<<"Your Entered string ";
	
	for(int i=0;i<9;i++)
		cout<<str[i]<<endl;//show the single word on screen
  return 0;
}
 
Share this answer
 
v2
Comments
Aescleal 14-Apr-12 5:15am    
gets a three from me as you're:-
- using quotes for system includes
- using stdafx.h (why add superfluous stuff the questioner doesn't need and won't compile straight out of the box on the majority of compilers - they'll complain about a missing include)
- using the most code intensive way of printing a string to stdout known to man and it only copes with 10 characters, anymore it'll probably crash on exit

However it does sort of work and it looks like a homework question, so hey for the good guys!

Cheers,

Ash

Edit: Unbalanced brackets in my English, how can lecture other people about code when I can't write my mother tongue???
First you create a Console application.
Next use console command to get input.
Then use console command and a loop through the input to display each letter entered.
 
Share this answer
 
Comments
Anderso0on 13-Apr-12 16:39pm    
i want read the string once after this output the alphabet char ,char ,char ....
Yes, I know. My solution has you do that. Try writing the code and you will see it does what you want.
 
Share this answer
 
It may useful for you try this


C#
static void Main(string[] args)
{
         string name = "Hello India";

         char[] MyCh= name.ToArray();
         for (int i = 0; i < MyCh.Length; i++)
             Console.WriteLine(MyCh[i].ToString());
         Console.Read();
}


OutPut:
H
e
l
l
o

I
n
d
i
a
 
Share this answer
 
Comments
Anderso0on 13-Apr-12 17:16pm    
i want with c++
Aescleal 14-Apr-12 5:10am    
This isn't C++

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900