473,503 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to calculate # of characters in a string

3 New Member
I need to write a small program about how to calculate number of characters in a string. I am getting a string from com port after every 15 second which also contains (*, @ $) symbols besides alphabets including spaces. Can anyone give me idea how to accomplish this task.
Dec 11 '06 #1
5 2166
horace1
1,510 Recognized Expert Top Contributor
I need to write a small program about how to calculate number of characters in a string. I am getting a string from com port after every 15 second which also contains (*, @ $) symbols besides alphabets including spaces. Can anyone give me idea how to accomplish this task.
If you can read the serial COM: port character by character you just check each characters as it is read. Otherwise if you read it as a string (e.g. into a char array) you would need to go thru the array after each read.
What operating system/compiler are you using?
Dec 11 '06 #2
gemni7
3 New Member
I am using borland 5.5 w XP
can u please give me any example or code so that I can understand the concept and write one. I thank you in advance
Dec 12 '06 #3
horace1
1,510 Recognized Expert Top Contributor
I am using borland 5.5 w XP
can u please give me any example or code so that I can understand the concept and write one. I thank you in advance
does you borland complier have the functions to read from the COM: ports?
Dec 12 '06 #4
gemni7
3 New Member
Yes I have that
Dec 12 '06 #5
horace1
1,510 Recognized Expert Top Contributor
Yes I have that
write a program to open the COM: port (setting baud rate, data bits, stop bits, etc) and attempt to read characters from it and display them on the screen. Once that is working you can start checking the characters

for example if you have a function rs_initialise() which initialises the port and a function rs_getch() which reads a character from the port the code would look something like
Expand|Select|Wrap|Line Numbers
  1.     rs_initialise("com1" ,57600, '8', 'N');
  2.     char letter;
  3.     while(1)
  4.      {
  5.       letter=rs_getch(port);
  6.       putchar(letter);
  7.       }
  8.  
Dec 12 '06 #6

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

Similar topics

1
9971
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a...
13
14226
by: Martin Herbert Dietze | last post by:
Hi, I need to calculate the physical length of text in a text input. The term "physical" means in this context, that I consider 7bit-Ascii as one-byte-per character. Other characters may be...
12
14441
by: paii, Ron | last post by:
Sorry about that last one. Does anyone know how to calculate the width a string of text for given Font name and size? I want to buildup a block of text strings to display in a unbound control,...
2
1622
by: strauchdieb | last post by:
hey everyone i try to figure out how to calculate string width in a textarea while typing in it. the textarea has a fixed start width. when the string gets longer as the textarea width, the...
13
3314
by: Angus | last post by:
Hello I have a stream of bytes - unsigned char*. But the 'string' may contain embedded nulls. So not like a traditional c string terminated with a null. I need to calculate the length of...
11
8859
by: Thomas | last post by:
Hi, I'm pretty new to the programming world. I got stuck in the following problem. Please guide me about it. Well I'm trying to get the value of (128^100)^2 I've used long double type but to no...
3
2720
by: vctiger | last post by:
could someone tell me how to calculate the size of a string constant?Thanks. The following is my source code which contain few bugs in it. #include <iostream> #include <string> using namespace...
26
8072
by: Prime Mover | last post by:
Hello all, I have got the pseudo-code below that I would like to convert to c language. The algorithm calculates Pi value. I am somewhat familiar with C language, but I am just starting to learn...
6
11346
by: LaundroMat | last post by:
Hi - I'm trying to calculate unique hash values for binary files, independent of their location and filename, and I was wondering whether I'm going in the right direction. Basically, the hash...
0
7207
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
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
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...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.