The format "%s"
is used to read a sequence of characters until a white space is encountered,
Instead of the conversion specifier %s
use the conversion specifier %c
if you are going to use a loop.
For example
int i = 0;
while ( i < n && scanf( "%c", str + i ) == 1 && str[i] != '\n' ) ++i;
str[i] = '\0';
Instead of the loop you could use the standard function fgets
as for example
#include <stdio.h>
#include <string.h>
//...
fgets( str, n + 1, stdin );
str[ strcspn( str, "\n" ) ] = '\0';
puts( str );
Pay attention to that the expression n + 1
shall be not greater than 101
due to this declaration
char str[101];