473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to count characters in a sentence eliminating spaces?

I want to count the characters of a sentence without reading any spaces.
Sep 27 '10 #1
4 2965
donbock
2,426 Expert 2GB
"... without reading any spaces."
Do you mean 'without counting any of the spaces'?

What is the format of the sentence. Typically such things are formatted as null-terminated strings, but there are other possibilities. It is up to you to find out.

When you say 'spaces', do you mean 'any whitespace'? For example, do you want to count tab characters, newlines, etc? It is up to you to find out what characters shouldn't be counted.

The count you want is the total size of the sentence minus the number of not-to-be-counted characters in the sentence. Treat each of these as a separate problem.
Sep 27 '10 #2
Oralloy
988 Expert 512MB
Juan,

This sounds like a homework question.

Why don't you try telling us what your requirements are and a preliminary solution. Once that's done, we can give you better help.

Cheers,
Oralloy
Sep 27 '10 #3
using a for loop, count the no of words and subtract the number of words from the value of i(when it reach the '\0')
Oct 1 '10 #4
donbock
2,426 Expert 2GB
Your first post says to count characters, your most recent post says to count words. Which is it?

How would you describe how to recognize the beginning and end of a word? (using words, not a computer program)

Your most recent post refers to "the value of i". You haven't told us anything about what variable i is.
Oct 1 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Oliver Saunders | last post by:
I was really shocked not to find this already submitted by someone in the PHP manual notes. <? function jnWordCount($text) { $results = array(); $pattern = '/+\S+/'; // matches wordy...
5
by: faizankhan666 | last post by:
Complete homework Question is this: Create a program that uses a do-while loop to count the number of char. (not including whitespace) entered by the user.The count should end when it encounters...
6
by: Jay | last post by:
I need to convert from a string a double that is followed by a scaling character (k means *1e3, M=*1e6, etc) then apply the scaling character. Example: "-1.345k #comment" I know roughly how...
25
by: Umesh | last post by:
Please try to do it while I try myself!
4
by: walterbyrd | last post by:
I don't know exactly what the first non-space character is. I know the first non-space character will be * or an alphanumeric character.
5
by: Dean | last post by:
Hi, I have a table with non-unique identifiers. I need to take all the values with the same ID's and combine them into one field with a semicolon as a seperator. These values may exceed 255...
3
by: cppman | last post by:
Hello, I am very new to C++ programming. I am trying to read a file with very large strings back to back, no commas or any other seperations between characters in a string and the size of the...
4
by: beary | last post by:
Since php seems to be able to do pretty much anything, is it possible for it to calculate the number of characters or words in a textarea as the user types? Eg. there is a 300 word limit, and as...
12
by: AdamOnAccess | last post by:
Hi, While the user is typing into a text box, I need to display the length of the string they are typing. My code is... displayCountLabel.caption = len(me!fieldTheyAreTypingIn) Problem is...
4
by: rvinodk | last post by:
Is it possible to search for a particular word in a string of words For Eg I am Crazy :)) Its a Crazy world It is a lovely day. If I input Crazy in a form, It should list the first 2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.