Right now I'm trying this:
#include <stdio.h>
int main(int argc, char *argv[]){
if (argc != 3){
printf("Usage: %s %s sourcecode input", argv[0], argv[1]);
} else {
char source[] = "This is an example.";
int i;
for (i = 0; i < sizeof(source); i++){
printf("%c", source[i]);
}
}
getchar();
return 0;
}
This does also NOT work:
char *source = "This is an example.";
int i;
for (i = 0; i < strlen(source); i++){
printf("%c", source[i]);
}
I get the error
Unhandled exception at 0x5bf714cf (msvcr100d.dll) in Test.exe: 0xC0000005: Access violation while reading at position 0x00000054.
(loosely translated from german)
So what's wrong with my code? Thanks in advance :)