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

basic C++ question, slighty confused too

2
I have a question about:

and i only know really basic c++ none of the really fancy stuff :(

How to convert integers into a string/character array?

and

How do I search for specific integers in the string/character array? (all the input is integers)

Any help is appreciated :)
Jul 12 '07 #1
4 1160
gpraghuram
1,275 Expert 1GB
I have a question about:

How to convert integers into a string/character array?

and

How do I search for integers in the string/character array?

Any help is appreciated :)
To convert integer to string u can use sprintf
sprintf(arr,"%d",integer);

To search for a integer in string or char array
you have to go character by character and use isdigit to check if it is a number


Raghuram
Jul 12 '07 #2
Voli
2
To convert integer to string u can use sprintf
sprintf(arr,"%d",integer);

To search for a integer in string or char array
you have to go character by character and use isdigit to check if it is a number


Raghuram

Thanks but can you explain it further ? and i updated/reworded my original post to make it more clear
Jul 12 '07 #3
I have a question about:

and i only know really basic c++ none of the really fancy stuff :(

How to convert integers into a string/character array?

How do I search for specific integers in the string/character array? (all the input is integers)

Any help is appreciated :)
How to convert integers into a string/character array?

I guess Raghuram has explained that clearly enough

How do I search for specific integers in the string/character array? (all the input is integers)

Assume the following declaration

char str="345633";

you want to search the number 5 in this.

loop through str. Any string in c is a character array.
So str[0]='3', str[1]='4',etc
So, to find the number 5, you have to search for the character '5', ascii value 48+5
Jul 12 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
If you are using C++, then use a stringstream:
Expand|Select|Wrap|Line Numbers
  1. int data = 1234;
  2. stringstream ss;
  3. ss << data;
  4. string str;
  5. ss >> str;
  6.  
and you are done.
Jul 12 '07 #5

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

Similar topics

9
by: Tom | last post by:
Hey all, I've been planning to get myself started with DocBook for quite some time now, so when I unexpectedly encountered a task for which DocBook might actually be very useful, I thought I'd...
7
by: asfwa | last post by:
I'm new to C++ and I have some basic questions. I have written an app that does some network stuff in a worker thread. The thread function requests something from the server, gets it and creates...
3
by: Yodai | last post by:
Hi all... I have this project on an embbeded system where I've programmed a very simple dynamic web-server on C, which serves 1 connection at a time. I need to implement a basic authentication...
6
by: pinorama123 | last post by:
I have an ASP.NET application that contains a few classes that I have built. One of my objects is a user object. I have a pretty basic question about how this would work. If I have multiple...
21
by: Roland | last post by:
The following issue is puzzling me: There are 2 ways of writing the code below: .... Dim fnt as Font = New Font(...) DrawString(myText, fnt,...) fnt.dispose(). or DrawString(myText, New...
2
by: anuragch1 | last post by:
#include <stdio.h> void main() { static int i = 1; void cal(); printf("%d\n",i); cal(); } void cal()
5
by: Vijay | last post by:
Hi All, I am not able to figure out what exactly happening in below code. what is control flow. Can anyone clear my confusion? Code: class A { public: A(){cout<<"In Constructor\n";}
3
by: Tenowg | last post by:
Hey guys, I know this is probably a very easy, basic question, so feel free to direct me to a detailed answer. I have done some searches some some of the information I get is vague. In C#, the...
2
by: splendid9 | last post by:
Hi all, i have a very basic css question. I already have a big css file with lot of classes init. div.text label.full, div.text2 label.full, div.text3 label.full, div.text4 label.full { ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.