Home   Notes   Contact Me

C


argv[0]

Windows Specific Gotcha! Sometimes under Windows, argv[0] does not contain the programs path, just the executables name, which may not include its extension (such as .exe) and may be of different capitalization then the program itself.


File Manipulation

Header: mostly in <io.h>

FunctionDescription
int _access( const char *path, int mode );determine file access permissions
int remove( const char *path );Deletes a file
int _chmod( const char *filename, int pmode );Change file permissions
int rename( const char *oldname, const char *newname );

Windows specific functions (mixed with others)

FunctionDescription
_access, _waccessCheck file-permission setting
_chmod, _wchmodChange file-permission setting
_fullpath, _wfullpathExpand a relative path to its absolute path name
_get_osfhandleReturn operating-system file handle associated with existing stream FILE pointer
_makepath, _wmakepathMerge path components into single, full path
_mktemp, _wmktempCreate unique filename
_open_osfhandleAssociate C run-time file descriptor with existing operating-system file handle
remove, _wremoveDelete file
rename, _wrenameRename file
_splitpath, _wsplitpathParse path into components
_stat, _stat64, _stati64, _wstat, _wstat64, _wstati64Get file-status information on named file
_umaskSet default permission mask for new files created by program
_unlink, _wunlinkDelete file

printf

format specifier %[flags][width][.precision][{h | l | I | I32 | I64}]type

Examples

flags

-Left Align
+Prefix the value with a sign [ + / - ]
0fills in width with zeros (ignored if width not specified)
'space'puts a blank space in front of positive values
#
oprepends 0
xprepends 0x
Xprepends 0X
e
E
f
always shows decimal point
g
G
always shows decimal point, and keeps trailing zeros

type

typeExampleDescription
cRchar type matching printf (or wprintf)
CRchar type opposite of printf (wide for printf, char for wprintf)
d-14int, signed
i83int, signed
o734int, unsigned, octal
u63000int, unsigned
xf135int, unsigned, hex with lowercase letters
XF135int, unsigned, hex with uppercase letters
e4.012e2float, Scientific notation
E4.012E2float, Scientific notation
f401.2float, Scientific notation
g401.2float, use shorter %e or %f
G401.2float, use shorter %E or %F
sHelloString of chars
pAf00:0134Address of pointer
nNothing printed, the arg must be a pointer that gets the number of chars printed

scanf

int sscanf( const char *zSrcString, const char *zFormatString, [arguments]);

Reading until but not including '\n', and including all white space: scanf( "%[^\n]s", buf);

format specifier %[*][max width][{h | l | I | I64}]type

return value is the number of fields successfully scanned

Item
*If included, it makes whatever this % causes to be scanned, get tossed, it is not stored into a variable
max widthMaximum number of chars to scan
? does this count the terminating 0?
h | l | I | I64Wierd Microsoft specific stuff
type
cchar type matching scanf (or wscanf)
Cchar type opposite of scanf (wide for scanf, char for wpscanf)
dsigned base 10
isigned base 10
ounsigned base 8
uunsigned base 10
xunsigned hex
e, E, f, g, Gfloat
nNumber of chars read up to this point
sString of chars whose type matches the scanf (or wscanf)
SString of chars whose type is the opposite of the scanf (or wscanf)

File attributes

NOTE: See also time, Maninpulating File Times


_stat
_stat64

time, Maninpulating File Times


_futime
_futime64
_utime
_utime64
utime [???}

Trigraphs

Here are the trigraphs:
CharTrigraph
#??=
[??(
{??<
\??/
]??)
}??>
^??'
|??!
~??-

Suppressing trigraphs:

DesiredUseDescription
???\?A backslash between the first and 2nd question mark
?????/?A trigraph escaped question mark between the first and 2nd question mark