1 Replies - 474 Views - Last Post: 14 August 2009 - 10:22 PM Rate Topic: -----

#1 Emon_MQ  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 37
  • Joined: 06-August 09

counting the sum of charecter in a string

Post icon  Posted 14 August 2009 - 10:21 PM

Hi,can any1 give me any idea how to count the sum of charecter in a string??
Is This A Good Question/Topic? 0
  • +

Replies To: counting the sum of charecter in a string

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,148
  • Joined: 07-September 06

Re: counting the sum of charecter in a string

Posted 14 August 2009 - 10:22 PM

You could make an int and loop through the string adding each character to the int as you go. That would give you the string sum, unless you are wanting to first take and transfer all the characters into their respective digits (0 through 9), at which point you would need to do that, and remove all non-numeric characters from the string.

Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: :code:

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1