isletter' : not all control paths return a value
-
i got this warning when i try to use isletter() in my WordDocu()
{ CString p[26]; CString v[26]; p[0] = "A"; p[1] = "B"; ...... p[24] = "Y"; p[25] = "Z"; v[0] = "a"; v[1] = "b"; .... v[24] = "y"; v[25] = "z"; for (int i = 0 ; i <26 ; i++) { if ( v[i] == str || p[i] == str) { return FALSE; break; } else if ( i==25 &&( v[i] != str && p[i] != str)) { return TRUE; } else { return TRUE; } } }
is there any path i dont wrote return TRUE/FALSE ? :/ -
i got this warning when i try to use isletter() in my WordDocu()
{ CString p[26]; CString v[26]; p[0] = "A"; p[1] = "B"; ...... p[24] = "Y"; p[25] = "Z"; v[0] = "a"; v[1] = "b"; .... v[24] = "y"; v[25] = "z"; for (int i = 0 ; i <26 ; i++) { if ( v[i] == str || p[i] == str) { return FALSE; break; } else if ( i==25 &&( v[i] != str && p[i] != str)) { return TRUE; } else { return TRUE; } } }
is there any path i dont wrote return TRUE/FALSE ? :/It doesn't look like it. Maybe you fooled the compiler by putting a break; after a return. And why have a for() loop if it always exits the first iteration? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
It doesn't look like it. Maybe you fooled the compiler by putting a break; after a return. And why have a for() loop if it always exits the first iteration? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
i want to know when a GetAt(i) is not letter (a-z A-Z) so it would be 1234567890!@$#^%^ etc i want this so i can find how many words exist in a string
-
i got this warning when i try to use isletter() in my WordDocu()
{ CString p[26]; CString v[26]; p[0] = "A"; p[1] = "B"; ...... p[24] = "Y"; p[25] = "Z"; v[0] = "a"; v[1] = "b"; .... v[24] = "y"; v[25] = "z"; for (int i = 0 ; i <26 ; i++) { if ( v[i] == str || p[i] == str) { return FALSE; break; } else if ( i==25 &&( v[i] != str && p[i] != str)) { return TRUE; } else { return TRUE; } } }
is there any path i dont wrote return TRUE/FALSE ? :/By the way, you could replace the entire function with a call to _istalpha (isalpha/iswalpha). Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
By the way, you could replace the entire function with a call to _istalpha (isalpha/iswalpha). Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
i had but it create a problem :P
-
i want to know when a GetAt(i) is not letter (a-z A-Z) so it would be 1234567890!@$#^%^ etc i want this so i can find how many words exist in a string
Immunity18 wrote:
want to know when a GetAt(i) is not letter (a-z A-Z) so it would be 1234567890!@$#^%^ etc
if (0 == _istalpha(str.GetAt(...)))
{
// not a letter
}I don't know what the problem with isalpha/iswalpha was... Regardless, look at your for loop - no matter what the condition, the function returns. To the compiler there's no return after the for loop. If the for loop condition fails before the first iteration, then no value is returned. We know the for loop will always execute (because for (int i = 0 ; i <26 ...) but the compiler doesn't. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Immunity18 wrote:
want to know when a GetAt(i) is not letter (a-z A-Z) so it would be 1234567890!@$#^%^ etc
if (0 == _istalpha(str.GetAt(...)))
{
// not a letter
}I don't know what the problem with isalpha/iswalpha was... Regardless, look at your for loop - no matter what the condition, the function returns. To the compiler there's no return after the for loop. If the for loop condition fails before the first iteration, then no value is returned. We know the for loop will always execute (because for (int i = 0 ; i <26 ...) but the compiler doesn't. Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
the _istalpha create me a problem and while it work fine for CStrings intiliaze and valued in code it dont work for CString (buf) from File.txt
-
the _istalpha create me a problem and while it work fine for CStrings intiliaze and valued in code it dont work for CString (buf) from File.txt
hmm well I never saw that code so I'm not sure why but it should work on any character you pass to it. There's nothing wrong with using your own function, but you probably want to fix it so it works properly :)
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
hmm well I never saw that code so I'm not sure why but it should work on any character you pass to it. There's nothing wrong with using your own function, but you probably want to fix it so it works properly :)
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
you can see my code with alpha in below post Different results when , compare 2 strings and 1 str with 1 str from file
-
hmm well I never saw that code so I'm not sure why but it should work on any character you pass to it. There's nothing wrong with using your own function, but you probably want to fix it so it works properly :)
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
can i ask something the isalpha how it works? i mean i want only A-Z a-z i dont want numbers and !@#$~>time isalpha work for that?
-
can i ask something the isalpha how it works? i mean i want only A-Z a-z i dont want numbers and !@#$~>time isalpha work for that?
That's exactly what it does. It returns non-zero if the character is A-Z or a-z. To find something NOT alphabetic then look for it to return 0. From the posts below, it doesn't seem that this is the problem. It looks like you need to step through your code and see exactly what's going on and in what order :) If you are looking for matching words then why are you looking for non-alpha characters. Don't you want to look for whitespace? MArk
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
That's exactly what it does. It returns non-zero if the character is A-Z or a-z. To find something NOT alphabetic then look for it to return 0. From the posts below, it doesn't seem that this is the problem. It looks like you need to step through your code and see exactly what's going on and in what order :) If you are looking for matching words then why are you looking for non-alpha characters. Don't you want to look for whitespace? MArk
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
whitespaces = " " ? That means this site (Codeproject) wouldn't reveal in my search because it is between ( ) ? i thought an alorithm if the letter in i isn't character + letter in (i-1) is character then we got a word "yes i think works correctly but not in my code :(" so here with that algorith it would find 10 words Well i will alt tab back to Visual studio and alchemy with isalpha To find something NOT alphabetic then look for it to return 0. i think this helped me :D
-
i got this warning when i try to use isletter() in my WordDocu()
{ CString p[26]; CString v[26]; p[0] = "A"; p[1] = "B"; ...... p[24] = "Y"; p[25] = "Z"; v[0] = "a"; v[1] = "b"; .... v[24] = "y"; v[25] = "z"; for (int i = 0 ; i <26 ; i++) { if ( v[i] == str || p[i] == str) { return FALSE; break; } else if ( i==25 &&( v[i] != str && p[i] != str)) { return TRUE; } else { return TRUE; } } }
is there any path i dont wrote return TRUE/FALSE ? :/it's so obvious that you forget to return after the loop. You may think that it will definitely return inside the loop (it loops 26 times) but at compile time, the computer can't tell whether the loop will be perform or not. To the compiler, a for() loop is one kind of structure that can be ignored, that's why you have to put a return explicitly after the loop.
-
it's so obvious that you forget to return after the loop. You may think that it will definitely return inside the loop (it loops 26 times) but at compile time, the computer can't tell whether the loop will be perform or not. To the compiler, a for() loop is one kind of structure that can be ignored, that's why you have to put a return explicitly after the loop.
GameProfessor wrote:
it loops 26 times
It loops once ;P
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder