hi,
I'm supposed to input a string from a file, strip its punctuation from it , and put its letters into an array. Is there some type of string function that can do that?
hi,
I'm supposed to input a string from a file, strip its punctuation from it , and put its letters into an array. Is there some type of string function that can do that?
No. Have you tried anything yet? I'll give you a hint:Is there some type of string function that can do that?
-create an array of the same length +1 of the original.
-loop through the string, and if you don't encounter punctuation(use ispunct() or write it by hand - easy), then copy to the second string.
-null terminate the second string.
-copy string 2 into string 1.
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
Not to my knowledge. Read the string on character at a time into the new string using a loop. i.e.
Code:char string[50]; char output[50]; //read to string here int a = 0; for(int i = 0; i < strlen(string); i ++) { //you could do this several ways. One is to check for a valid character value: if ((string[i] >= 97 && string[i] <= 122) || //lowercase a-z (string[i] >= 65 && string[i] <= 90)) //upercase a-z { output[a] = string[i]; a ++; } } OR //Alternatly you could check in the for loop like this by weeding out specific punctuation instead of only allowing characters if (string[i] != '.' && string[i] != '!' && string[i] != '?') //etc, etc... { output[a] = string[i]; a ++; }
"There's always another way"
-lightatdawn (lightatdawn.cprogramming.com)
check out ispunct( int ), found in <ctype.h>. It could be useful...
Couldn't think of anything interesting, cool or funny - sorry.
I fixed it. Cant believe I didn't think of this stuff before!!