Code:
#include <stdio.h>
#include <stdlib.h>
#define MAX_READ 2
int main( )
{
char * secret = "abecedarium consisting This is a string literal!";
char command[MAX_READ], string[MAX_READ];
sscanf(secret,"%s%s",command, string);
printf("%s %s\n",command, string);
return 0;
}
compiling options: gcc -g -Wall -ansi -pedantic testes.c -o tt
i am trying to test what happens in the sscanf converted types (command and string) if they are smaller, i got surprised that the printf worked, so i dont know why.
this code is just a test for what i want to do, what i really want to do is for example: i have this string from the stdin which must have the following format:
connect name.surname
so i need to check the cases when it is not the input that i want, nammely if the name.surname is for example bigger than 30 chars. and also if it has the abecedary characters from the ascii,