UMASK function in C
The file creation mode you specified is in decimal format. File creation modes are typically specified in octal, so you should prefix the number with a leading 0, which tells the compiler it is an octal constant.
creat("a.txt",0666);
Decimal 666 = octal 1232, which matches up with the result you got.
Please refer to your friendly man page (man 2 umask
) or to this one.