count the number of charaters in a string

count the number of charaters in a string

Page 1 of 1

6 Replies - 2624 Views - Last Post: 16 February 2009 - 04:27 AM Rate Topic: -----

#1 skisky1989   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-February 09

count the number of charaters in a string

Post icon  Posted 15 February 2009 - 09:43 PM

simple enough.....

i have found examples for counting words, spaces are used to count words.

but characters.....
its so simple it seems hard.
Is This A Good Question/Topic? 0
  • +

Replies To: count the number of charaters in a string

#2 n8wxs   User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: count the number of charaters in a string

Posted 15 February 2009 - 10:03 PM

Simple? :)

See Char.IsLetter Method (String, Int32)
Was This Post Helpful? 0
  • +
  • -

#3 skisky1989   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-February 09

Re: count the number of charaters in a string

Posted 15 February 2009 - 10:07 PM

hmmm, how would i incorporate a string?

they use a char.

not quite clear here....(example from MS)

using System;

public class IsLetterSample {
	public static void Main() {
		char ch = '8';

		Console.WriteLine(Char.IsLetter(ch));					// False
		Console.WriteLine(Char.IsLetter("sample string", 7));	// True
	}
}



Was This Post Helpful? 0
  • +
  • -

#4 n8wxs   User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: count the number of charaters in a string

Posted 15 February 2009 - 10:17 PM

Console.WriteLine(Char.IsLetter("sample string", 7)); // True
What do you call the characters between the double quotes? :) :)

string example = "sample string";
int charCounter = 0;

for (int i = 0; i < example.Length; i++)
   if (Char.IsLetter(example [i])
	  charCounter++;


Was This Post Helpful? 0
  • +
  • -

#5 skisky1989   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-February 09

Re: count the number of charaters in a string

Posted 15 February 2009 - 10:20 PM

****.......Bangs head on desk.........***

maybe i need to make some coffee...haha
Was This Post Helpful? 0
  • +
  • -

#6 skisky1989   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 11-February 09

Re: count the number of charaters in a string

Posted 15 February 2009 - 10:41 PM

i see that i cannot send you a message, would you by any chance mind looking at a C program i am working on...im having a trouble compiling it...

probably a dumb mistake in my calctotal function i cant see
Was This Post Helpful? 0
  • +
  • -

#7 n8wxs   User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: count the number of charaters in a string

Posted 16 February 2009 - 04:27 AM

View Postskisky1989, on 15 Feb, 2009 - 09:41 PM, said:

i see that i cannot send you a message, would you by any chance mind looking at a C program i am working on...im having a trouble compiling it...

probably a dumb mistake in my calctotal function i cant see

Post it over in the C and C++ forum
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1