Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-25-2007, 08:10 AM
fire exit fire exit is offline
Newbie
 
Join Date: Jul 2007
Posts: 9
Rep Power: 0
fire exit is on a distinguished road
Default C++ read each character of the word?

another newbie question. how can i read or print each letter of a certain word?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 09-25-2007, 08:29 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

When you say "word," what do you then mean?
Usually there's two ways of using strings/words; C-strings and C++-string.
Code:
#include <string> // This is for C++

// C-strings
char *MyCString = "Hello, World!";
printf("%c\n", MyCString[0]); // Print first character (H)
printf("%c\n", MyCString[1]); // Print second character (e)

// C++-string
std::string MyCPPString = "Hello, World!";
std::cout << MyCPPString.at(0) << std::endl; // Print first character (H)
std::cout << MyCPPString.at(1) << std::endl; // Print second character (e)
Note that the std::string-objects have support for the index-operators as well. So you can do with C++-strings like with C-strings, but not in reverse order.
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-26-2007, 02:21 AM
fire exit fire exit is offline
Newbie
 
Join Date: Jul 2007
Posts: 9
Rep Power: 0
fire exit is on a distinguished road
Default

that is exactly what i want!! thanks!!!.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dictonary Program programmer 101 Java Help 9 07-01-2007 02:39 PM
Need help w/ word count program (ASAP) siren C and C++ 1 04-23-2007 09:14 AM
Moving charts fom excel to word. priorityone Computer Software/OS 4 01-07-2007 06:19 AM
PERL - Split by Character Cosmet Perl 2 12-30-2006 02:03 PM
Linking one word to another on same page PC101 HTML Programming 4 09-21-2006 01:38 PM


All times are GMT -5. The time now is 02:24 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads