I am looking for a clown to replace me as a regular on these forums. You won't receive payment but you can consider it a service to the cprogramming.com community! Anyone who's interested in this...
Type: Posts; User: Barney McGrew
I am looking for a clown to replace me as a regular on these forums. You won't receive payment but you can consider it a service to the cprogramming.com community! Anyone who's interested in this...
One other common use is to get the number of elements in an array. This can be used like so:
int x[10];
size_t i;
for (i = 0; i < sizeof x / sizeof x[0]; i++)
x[i] = 1;
What you have is fine as it is; it's an error to dereference currentP->next if currentP->next stores a null pointer. Your code will ensure that currentP->next isn't dereferenced in such a case.
...
qsort requires each element to be of the same length so, obviously, you can't move strings around in an array using it, since they may have different sizes. What you need to do is store a pointer to...
Try another source: qsort(3) - Linux manual page
Yeah. Make your program data-oriented, so that all the information you spam the user with is stored in one place, then write your program so that it operates on that data.
Why not use a growing array to store the input? Your program would be more portable since you won't need to use stat.
In regard to your compare function, try reading the example provided in 'man...
',' is evaluated after '='.
Why don't you just do this?:
#include <stdio.h>
int printmac(const unsigned char ptr[6])
{
return printf("%02x:%02x:%02x:%02x:%02x:%02x\n",
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4],...
Some men annoy a lad called waitpid with their concerns.
Violence never solves anything. Try again when you're ready to use your keyboard properly.
How about completely rewriting it?
static int pali_(const char *start, const char *end)
{
return start >= end ? 1 : *start == *end && pali_(start + 1, end - 1);
}
int pali(const char *s)
{...
You can't do this in standard C, so find an external library that will do what you want and, if you have trouble with that library, you'll surely get better help by asking the people who maintain...
C's written in English, though compilers and interpreters for it are written in a variety of languages. You even see C implementations that use multiple programming languages, for instance, a...
You don't want to use calloc for pointer types, since it initialises them with all bits zero, which is a meaningless value for pointers. malloc would be a better choice and, if you need them...
char *strcat(char *s, const char *append)
{
return strcpy(s + strlen(s), append), s;
}
Figure out how to implement strcpy and strlen, and it should be simple enough to understand.
@megafiddle:
Well, I started writing a response, but most of what I was writing seemed to be the same points made in 'C For Smarties', so I'll just post a link to that.
C For Smarties
It's implementation-dependent. Your system should provide a way to redirect your program's output to a printer.
EDIT: On most Unix-like systems that's as easy as:
./program > /dev/lp
You could...
I see. This makes me wonder about code like:
int a[3][10];
a[0] < a[2];
Would you say it has undefined behaviour? On the one hand, both pointers point into separate aggregates, but on the other,...
'void *' and 'char *' are both able to represent all object pointer types. (6.2.5p28, 6.3.2.3p1)
Could it be that when two pointers are cast to 'void *', that the destination pointers are...
'\n'
You'll need to include <stdlib.h> to make the declaration for qsort available as well. It's also a good idea to terminate your program's output with a new-line character.
Looks like somebody needs a diaper change!
In your first post you mentioned that the size would be eight bits for the header field. Assuming you're referring to the packed size and that CHAR_BIT is 8, I think you want the following:
unsigned...
Are you sure it has undefined behaviour, rather than unspecified behaviour? If it were true I think that would make it impossible to implement memmove() in a standard-compliant manner.