cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Problems with a C string and its ascii c
Problems with a C string and its ascii code
Mar 4, 2010 at 3:24pm UTC
acbay91
(1)
hey guys so in my C++ program i have a function that evaluates an input string from a file.
so i just want to show you my function really quick:
int code(char *input, double &val1)
{
int count = 0;
int pos = 0;
for (pos = 0; pos < sizeof(in); pos++)
{
if ((in[pos] <= '41)||(in[pos] == 44)||(in[pos] >= 58))
{
cout << "ERROR" << endl;
count = 0;
}
}
return count;
}
my problem here is that suppose the input string is 345
the function still outputs "ERROR" but in theory it should not be outputting anything right?
Mar 4, 2010 at 3:29pm UTC
imi
(426)
Please use [ code ] tags around your program (you can edit your own post to do this very easy). And you should check whether you copy'n'pasted it correctly from your source file. Some parts look strange.. (e.g. "...<= '41)||...")
Topic archived. No new replies allowed.