#include <stdio.h>
#include <assert.h>
#include <string.h>

#define BUFSZ 4 
int main() {
    char attrValue[11]="keshakesha";
    char fmtString[10] = {0}; //there's no need for this one to be BUFSZ in length
    char scanBuf[BUFSZ];

    //create a format string in fmtString; limit the scanned string to one less than BUFSZ
    snprintf(fmtString,sizeof(fmtString),"%%%ds",BUFSZ-1);
    printf("format string created for sscanf: %s\n", fmtString);
    
    //scan from attrValue into scanBuf, using the format string created above
    int num=sscanf(attrValue,fmtString,scanBuf);
    
    printf("items read: %d\n", num );
    printf("string read: %s\n", scanBuf );

    return 0;
}
