473,385 Members | 1,753 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,385 software developers and data experts.

how to access parts of string in c

1
hi

how does one access parts of string in C.

string comes back like this in Hyperterminal

LITL0 0000
LITL1 0759
LITL2 0014
LITL3 0024

need to access the numbers
is there a function in C similar to substr in C++?

thank you
May 4 '07 #1
2 2024
Ganon11
3,652 Expert 2GB
You can use strtok() to seperate the string by spaces and get to the numbers. See more on strtok() here.
May 4 '07 #2
AdrianH
1,251 Expert 1GB
LITL0 0000
LITL1 0759
LITL2 0014
LITL3 0024

need to access the numbers
is there a function in C similar to substr in C++?
You can use scanf() or sscanf() but you need to take some pecautions when using them. I usually use a %n to ensure that that point has been gotten to in the parse.

Expand|Select|Wrap|Line Numbers
  1. int position = 0; // must be initilised
  2. scanf("LITL%*[0-9] %d%n", &number, &position);
  3. // check that position is not 0.
  4.  
FYI, be careful about parsing numbers starting with 0. C/C++ libraries may parse them as octal (base 8) instead of decimal (base 10). You may wish to strip the leading zeros prior to using a C/C++ library function.

If you are still having problems, let us know.


Adrian
May 4 '07 #3

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

Similar topics

0
by: Dannie Chan | last post by:
Hi, I'm new in VB.NET, I writing a VB.NET program access MSAccess database. If recevied parts, than add received items into the MS Access database. Production software will create a xls files...
1
by: David | last post by:
Hi everyone. I have read every page that Google returns on this topic, but can't find anything that resolves my problem. Basically, I have an Access Database that does a number of different...
11
by: Rosco | last post by:
Does anyone have a good URL or info whre Oracle and Access are compared to one another in performance, security, cost etc. Before you jump on me I know Oracle is a Cadillac compared to Access the...
6
by: Marlene | last post by:
Hi All I have the following scenario, where I have found all the duplicates in a table, based on an order number and a part number (item).I might have something like this: Order PODate Rec...
1
by: Colin Graham | last post by:
i am currently developing an asp.net web application which is linked to an Access database. The main problem that i have is in creating a global pathname that i can access. When i put my string...
42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
3
by: MattC | last post by:
Hi, I found this code somewhere on the net and need to make some alterations. public class GenericSorter : IComparer { String sortProperty; bool sortOrder; public GenericSorter(String...
27
by: SQL Learner | last post by:
Hi all, I have an Access db with two large tables - 3,100,000 (tblA) and 7,000 (tblB) records. I created a select query using Inner Join by partial matching two fields (X from tblA and Y from...
8
by: bill | last post by:
Turning on error_reporting(E_ALL); was quite an eye opener as to how much "fixing" PHP will do for the sloppy coder. I fixed all of the errors except: Notice: Undefined property: parts in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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:
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
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...

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.