drspangle
New member
Right, dead easy: a basic string to lowercase converter, I`ve used it a thousand times, it`s practically identical to ones I`ve found on the net, same as lecture notes etc etc etc. I will point out again, I have been using this function for ages, with never a ptoblem. THEN WHY IN THE HOLY HELL IS IT SEGFAULTING NOW?
I`ve wasted 2 hours with this, and it`s retarded because It`s copied and pasted code that I`ve used a million times.
Any ideas? I will reboot in the vain hope that something has gone retardedly wrong somewhere
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void lowercase(char *string);
int main(void){
lowercase("FRED");
return(0);
}
void lowercase(char *stringIn)
{
int counter = strlen(stringIn);
printf("You inputted: %s\n",stringIn);
while (*stringIn != '\0'){
*stringIn = tolower(*stringIn); [COLOR="Red"]<======== here![/COLOR]
*stringIn++ ;
}
stringIn-=counter;
printf("New string is: %s\n",stringIn);
}
I`ve wasted 2 hours with this, and it`s retarded because It`s copied and pasted code that I`ve used a million times.
Any ideas? I will reboot in the vain hope that something has gone retardedly wrong somewhere