473,320 Members | 2,145 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,320 software developers and data experts.

counting letters in a string(for c language)

hey
can somebody please explane how to count letters in a string. thxs
Jul 15 '07 #1
4 6586
gpraghuram
1,275 Expert 1GB
hey
can somebody please explane how to count letters in a string. thxs
The logic used for counting letters in a string is to treat it as an array and traverse it character by character by incrementing the index of the array till the end of string is reached.
Hope this solves ur purpose

Raghuram
Jul 16 '07 #2
DaveP
4
The logic used for counting letters in a string is to treat it as an array and traverse it character by character by incrementing the index of the array till the end of string is reached.
Hope this solves ur purpose

Raghuram
If you're using a standard 'c' or 'c++' and they are normal null terminated strings then include <string.h> and do a strlen(pointertostring);

so, for example:

char *mystring = "The quick brown fox";
int length = strlen(mystring);

In Visual C++ you should use the System::String class and you can get the length as follows:

String mystring = new String("The quick brown fox");
int length = mystring->Length;

If you don't have the luxury of doing it this way, the loop for counting a string length is very simple;

char *mystring = "The quit brown fox";
int length = 0;

while(mystring[length] != '\0')
length++;

Hope this helps
Jul 16 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
In Visual C++ you should use the System::String class and you can get the length as follows:
There is no System class in ANS/ISO C++. You are referring to Visual C++.NET, which is Microsoft specific.
Jul 16 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
hey
can somebody please explane how to count letters in a string. thxs
Do you mean count letters, like A to Z? Or do you mean count any characters in the string??

The answer will be different based on your reply.
Jul 16 '07 #5

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

Similar topics

7
by: Bart Nessux | last post by:
I have some php scripts that I use on several machines. Each machine has an identical copy of a mysql database that the scripts run against. The only differences in the DBs are the user names and...
9
by: Mosher | last post by:
Hi all, I was wondering if php can parse a text string for certain words and return "true" if that word is found. For example, I have a string like this: $string = "The rain in spain is the same...
0
by: Lance | last post by:
Hi All, I created a user control and put it on a form with a data repeater and ado control. My understanding is that this configuration requires a connection string. However, my database is in...
3
by: Varun | last post by:
I have a solution which contains windows,web,mobile presentations. Now i want to share the connection string in the web.config file. i want to write a method in a common layer where i can retrieve...
1
by: robert demo via AccessMonster.com | last post by:
I'm trying to retrieve the connection string for a linked table in a backend that is password protected. I've modified the code shown below to temporarily check that the backend has been...
3
by: Quentin Huo | last post by:
Hi: If I have a query string for retrieving data from SQL Server database, is there a way to transfer it to a query string for retrieving data from Oracle or any other database like mySQL...? I...
0
by: haridelphi | last post by:
hi this is my 2 post in this forum.Please anybody tell me the Connection string for Borland developer studio 2006 (ASP.NET,C#) with postgreSQL 8.1 platform : Borland developer studio 2006...
2
by: arnuld | last post by:
I use capital letters for macros only. Is it a good idea to use all capitals for things like constant variables and variables and array in global namespace ? --...
34
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.