|
How to get your string?from a editbox...?its for only number or string?
|
|
|
|
|
Use isdigit() .
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
-3.2 is a valid numeric number ; BTW, - and . characters won't be validate by isdigit() though
|
|
|
|
|
True. Those two characters would need to be handled individually. However, a string such as "3.2-" would not be considered a valid number even though it has only . (dot), - (dash), and digits. sscanf() could be used, depending on the tolerances.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You can use the isalpha(int c) to verify each character or you string. If any call to this function returns 1, your string is not composed only by numbers.
|
|
|
|
|
isalpha('}'); will return false, however, the string is not composed only by numbers...
your method has serious lacks
|
|
|
|
|
I just want to practice class using, but met this problem:
fatal error C1004: unexpected end of file found.Could anyone lend me a help,thank you!
Code:
// prac.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "iostream"
using namespace std;
class polygon{
protected: int width, height;
public: polygon(int,int);
virtual int area ()
{ return (0); }
};
polygon::polygon(int a,int b)
{
width=a;
height=b;
}
class triangle: public polygon{
public: int area(){
return(width * height/2);
};
class quadrangle:public polygon{
public: int area()
{return (width * height);}
};
void main(int argc, char* argv[])
{
quadrangle ax(10,5);
triangle bx(10,5);
cout << "ax area: " << ax.area() << endl;
cout << "bx area: " << bx.area() << endl;
}
|
|
|
|
|
this is unmanaged C++ ask the correct forum.
|
|
|
|
|
sorry, what does that mean? how to solve it?
|
|
|
|
|
|
toxcct wrote: ask the correct forum[^]...
Hey Tox,
The thread has been moved to the unmanaged C++ forum.
|
|
|
|
|
it wasn't when i wrote it
but yup, you're right
|
|
|
|
|
toxcct wrote: it wasn't when i wrote it
I know. In general, unless a thread changes mid-way into a managed question (or an unmanaged question) in the wrong forum, it's best to leave it for a day or two (without replying) so someone can move it to the right forum
Strange though that people can't even decide the correct forum to post their questions. They see the word 'C++' and bang - make their post!
|
|
|
|
|
i think also many people don't even know what managed C++ is (and whant managed actually means !!), and when one has a general question about C++, the fact that the main C++ forum contains "visual" in its name might tell them, "it's certainly not what i want to ask about, so, i'll go to the other C++ forum"...
|
|
|
|
|
It looks that the definition of class triangle has one "}" missing.
Best,
Jun
|
|
|
|
|
Hi,
This happens when you skip somewhere closing bracket "}".
Double check your source code.
|
|
|
|
|
1111-----1
1 11------
1111----1-
--------111
--------111
--------111
hi, as the previous question may not so easy to see, so i post the question out again here..
this is just only a example, and using C++ to solve plenty of these similiar example.
In this problem, you can ignore all the - simbol as they stand for the space only, and you can see that:
the hole formed inside many 1 consider call void element=V; here v = 1
two 1 which is quite far away from others is call exceptional element=E,here E = 2;
let the total number of 1 =A; here A = 22
i need to use the C++ to calculate the below result
S = (A-E)/(A+V)
for example this case s = (22-2)/(21+1)=0.91
So how to write a C++ program, to search for the void element V; the exception element E as well as the total number of 1 A and calculate the result??
i am so eager to know the knowledge about this, may anyone give me a hand???
Your great help will be appreciated!!, thank so much.
please send to my email sinbearzc@hotmail.com if you can give me a help, thank..
|
|
|
|
|
Your question is not clear at all. What are these spaces and '1' ? Is that data contained in a file that you need to read ? Or what ?
When describing a problem, try to imagine people reading you. What you describe is just too abstract for us to understand (at least, for me to understand )
sinbear wrote: please send to my email sinbearzc@hotmail.com if you can give me a help, thank..
No way, this is a forum so if we have an answer, we'll post on the forum.
|
|
|
|
|
sinbear wrote: the hole formed inside many 1 consider call void element=V; here v = 1
Here you mean this line 1 11------ yes? Did you make a mistake? Should the line be 1-11------ ? You say a hole inside many 1's. How many? In your example there are 3 1's.
sinbear wrote: two 1 which is quite far away from others is call exceptional element=E,here E = 2;
quite far does not explain enough. Do you mean when there is more than 1 space between the 1's?
Your example shows multiple lines. How exactly do you read the numbers? Are they binary or ASCII, does the file also contain lines (with a CLLF at the end of each line) or is it a continuous stream?
Before anybody can help you, you must answer all of my questions.
|
|
|
|
|
sinbear wrote: the hole...
What's a "hole?" Are you wanting to detect a space surrounded by 1 s?
sinbear wrote: two 1 which is quite far away from others...
What exactly does this mean?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
they must be very lonelly ones !!!
|
|
|
|
|
True. One is the loneliest number.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
111100001
1 1100000
111100010
00000000111
00000000111
00000000111
ok, now i change the - to 0, to try to explain this example more clear, this file will be print out in txt format, require the c++ to read from the txt file and also, it is the birnary format, and now can see that
the void V is the whole among the group of 1,
1111
1 11
1111
the two exceptional 1 E is locate at:
00001
00000
00010
which consider at not inside the group of 1
and like this
111
111
111
will consider as a group of 1
and so S = (A-E)/(A+V)
is this help to explain the problem? thanks
|
|
|
|
|
sinbear wrote: the void V is the whole...
What value does this "hole" have? Given that, just search for this value and you've found the void. Or, if you say that the file is comprised of only 0 s and 1 s, anything else would be considered a void. Correct?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi all
I want to find out how to idendify if a string is unicode or ansi at run time.
Please help me ...
regds
Dharani
redindian
|
|
|
|