How can i store all the character within the range that i had stated in a string ??
eg like if i enter a-j, it will store abcdefghij in the string.
How can i store all the character within the range that i had stated in a string ??
eg like if i enter a-j, it will store abcdefghij in the string.
char alpha[] = "abc";
search the array until you find the start letter
copy the letters until you find the end letter
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
What this code does is it passes the character range to the validateString function, eg a-e. But currently i have problem storing back the character into the string array. How can i solve this problem ???
Code:int validateString(char *sC, char *rC) { char* tempArray = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; int start; int end; int boolcounter = 0; char temp[30]; int i=0; start = *rC; rC++; rC++; end = *rC; while (*tempArray != end + 1) { if(*tempArray == start) { boolcounter = 1; } if(boolcounter == 1){ temp[i++] = *tempArray; // PROBLEM } tempArray++; } return 1; }
I suggest you pass temp as a parameter to the function.
void func ( char *buffer, char start, char end )
Don't forget to add a \0 to the end of any string you create.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.