I’m new to C programming, though experienced with C#. What I’m trying to do it to walk through my char array and replace ‘a’ with ‘x’ and print that to the screen. Somehow this doesn’t works … whyever 😉
Using gcc 2.2.4 on Debian 6 64bit
#include <stdio.h>
int main()
{
/* A nice long string */
char string[256];
int i;
printf( "Please enter a long string: " );
/* notice stdin being passed in */
fgets ( string, 256, stdin );
for( i = 0; i < 256; i++)
{
if( string[i] == 'a' )
{
string[i] == 'x';
printf("%s", "foo");
}
}
printf( "You entered a very long string, %s", string );
getchar();
}
You have a double equal
Do it like this: