Categories

What is a pointer?

One of those things beginners in C find difficult is the concept of pointers. The purpose of this tutorial is to provide an introduction to pointers and their use to these beginners.

I have found that often the main reason beginners have a problem with pointers is that they have a weak or minimal feeling [...]

is the floppy disk ready

#include
#include

void main(void)
{
char buffer[8192];

// Try reading head 1, track 1, sector 1
if (biosdisk(2, 0, 1, 1, 1, 1, buffer))
printf(“Error accessing driven”);
else
printf(“Drive readyn”);
}

Bookmark It

get the size of a file

#include
#include
#include
#include

int main()
{
int fp;

long file_size;

if ((fp = open(“f:/cprojects/urls.txt”, O_RDONLY)) == -1)
printf(“Error opening the file n”);
else
{
file_size = filelength(file_handle);
[...]

file attributes

#include
#include

int main()
{
int mode;
/*check a files attributes*/
mode = access(“f:/cprojects/urls.txt”,0);
if(mode)
printf(“File does not exist.n”);
else
/*check if the file can be written to*/
mode = access(“f:/cprojects/urls.txt”,2);
if(mode)
printf(“File cannot be written.n”);
else
printf(“file can be written to.n”);

/*check if file can be read*/
mode = access(“f:/cprojects/urls.txt”,4);
if(mode)
printf(“File cannot be read.n”);
else
printf(“File can be read.n”);

/*check if afile can be read/written*/
mode = access(“f:/cprojects/urls.txt”,6);
if(mode)
printf(“File cannot [...]

feet metres centimetres conversion

#include

int main()
{
float feet,metres,centimetres;
printf(“Enter the amount of feet you wish to convert.n”);
scanf(“%f”,&feet);

while(feet > 0)
{
centimetres = feet * 12 * 2.54;
metres = centimetres / 100;
printf(“%6.2f feet is equal to n”,feet);
printf(“%6.2f metresn”,metres);
printf(“%8.2f centimetresn”,centimetres);
printf(“Enter another value to be converted or n”);
printf(“enter 0 to exit.n”);
scanf(“%f”,&feet);
}
return 0;
}

Bookmark It