#include <memory.h>
#include <stdio.h>
void iterate_through_string(char *lpString)
{
printf("Full string: %s\n", lpString);
char c;
while((c = *lpString++))
{
printf("-- %c\n", c);
}
}
int main()
{
char *my_string = (char *)malloc(25);
sprintf(my_string, "rawr rarara ! what ._.?");
char *my_other_string = "blah blah blah boring";
iterate_through_string(my_string);
printf("Same string again: %s\n", my_string);
iterate_through_string(my_other_string);
printf("Same string again: %s\n", my_other_string);
free(my_string);
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.