A2osX/ROOT/ctest/testptr.c.txt

77 lines
1.6 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <md5.h>
void *someptr = NULL;
void *pBuf = malloc(256);
int iarray[8];
float farray[4][5];
int *parray[];
int main(int foo, char *bar[]) {
puts("Testptr...");
printf("someptr = %H:%H, pBuf = %H:%H\r\n", &someptr, someptr, &pBuf, pBuf);
getchar();
parray=&iarray;
printf("parray = %H:%H\r\n", &parray, parray);
getchar();
printf("iarray = %H:%H:%H:%H\r\n", &iarray, iarray, iarray[0], iarray[1]);
getchar();
iarray[0]=513;
iarray[1]=1026;
printf("iarray = %H:%H:%H:%H\r\n", &iarray, iarray, iarray[0], iarray[1]);
getchar();
*parray[0]=258;
*parray[1]=516;
printf("parray = %H:%H:%H:%H\r\n", &parray, parray, parray[0], parray[1]);
getchar();
farray[1][1]=3.14;
printf("farray: %e\r\n", farray[1][1]);
printf("foo = %D, bar = %H:%H:%s:%s\r\n", foo, &bar, bar, bar[0], bar[1]);
getchar();
md5("PASSWORD", pBuf);
printf("MD5=%s\r\n", pBuf);
getchar();
getenv("TERM", pBuf);
printf("TERM=%s\r\n", pBuf);
getchar();
setenv("TEST", "Value");
getenv("TEST", pBuf);
printf("TEST=%s\r\n", pBuf);
getchar();
short int hFile = fopen("testptr.c", O_RDONLY, 0, 0);
printf("hFile=%d\r\n", hFile);
int linecnt=0;
while (NULL == fgets(hFile, pBuf, 255)) {
linecnt++;
printf("%5D:%s\r\n", linecnt, pBuf);
}
fclose(hFile);
getchar();
free(pBuf);
puts("All done.");
}
MAN
TEXT root/ctest/testptr.c