Posted by Anonymous Sat 17th Mar 2007 10:40 - Syntax is C - 40 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
-
#include
-
#include
-
-
unsigned int string_length( char * string )
-
{
-
unsigned int string_length;
-
for ( string_length = 0; string[string_length] != '\0'; string_length++ )
-
{
-
string_length = string_length + 1;
-
}
-
return ( string_length - 1 );
-
}
-
-
char * reverse_string( char * string )
-
{
-
int length = string_length( string );
-
char * reversed_string = malloc( length + 1 );
-
if ( reversed_string != NULL )
-
{
-
int each = 0, each_reversed = length - 1;
-
while ( each_reversed >= 0 )
-
{
-
reversed_string[each] = string[each_reversed];
-
each++; each_reversed--;
-
}
-
return reversed_string;
-
}
-
}
-
-
char * squeese( char * string )
-
{
-
char * squeesed_string = malloc( sizeof( string ) + 1 );
-
int each, character;
-
for ( character = 0, each = 0; string[character] != '\0'; character++, each++ )
-
{
-
if ( string[character] == string[character + 1] )
-
{
-
each--;
-
continue;
-
}
-
squeesed_string[each] = string[character];
-
}
-
return squeesed_string;
-
}
-
-
int main( )
-
{
-
char string[] = "hammad";
-
}
PermaLink to this entry https://pastebin.co.uk/11950
Posted by Anonymous Sat 17th Mar 2007 10:40 - Syntax is C - 40 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Comments: 0