473,657 Members | 2,776 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 2170
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
9982
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 number. That number will appear in a seperate box at the bottom. So basically whatever you choose has a corresponding number associated with it (except for the text input, which you enter whatever number) and those numbers are added and produced in...
13
14254
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 longer, e.g. cyrillic would be 2 bytes per character. Is there a safe and easy way to notice non-7bit-Ascii input? Cheers,
12
14487
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, that has limited width but multiple lines. Currently I am using the left$() function to trim the text to a standard number of characters. I want a function to return the number of characters that will fit in the width of the control. To keep the...
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 textarea should be made bigger while typing programatically. my only problem is to determine the size of the string in the textarea. i know the font family and font size.
13
3321
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 these arrays but can't use strlen because it just stops counting at the first null it finds. so how to do it? Angus
11
8876
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 avail. I even can't get the value of 2^128. How this problem can be solved? Similarly, I was trying to develoop a program in hich we can calculate
3
2734
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 std; int main() { string s="hello world"; int *ptr;
26
8096
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 parallel programming. In this specific example, the idea seems to be simple: one must subdivide the main loop into pieces that can be executed by independent "tasks" (computers??). Then, each "worker task" executes a part of the loop a...
6
11363
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 values are calculated thusly: f = open('binaryfile.bin') import hashlib
0
8403
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5636
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.