Hi all,
the object is to write a function called say remchar that recieves a string say 'Hello' and a character 'o'.
The function should loop through the string look for the character passed 'o' if it exists which it does, rmove the character from the string and pass it pack to main to print out the modified string.
here is what I have so far and won't compile.
The compile error isCode:#include <stdio.h> int main() { char strin[10]={'H','e','l','l','o'}; //init a char string called strin char chr = 'o'; //character var to pass to function to look for printf("\nstring before function call\t:>%s", strin); //print the string pre call remchar(strin, chr); //call remchar func printf("\nstring after function call\t:>%s\n", strin); //string post call return 0; } remchar(strin, chr) { int i; for(i = 0; strin[i] != '\0'; i++) //start for loop { if(strin[i] == chr) //test for character { strin[i] = strin[i] + 1 ; // write next character back to current position } } }.subscripted value is niether array nor pointer
I haven't seen this one before!
Also can any one give me a bit of clarity on how to handle modifying arrays etc? I am not looking at pointers yet!
Any help is much appreciated
Thanks



LinkBack URL
About LinkBacks


