How about something like:
/**
* remstrchr - Remove all occurrences of character "c"
* from string "string". Returns the modified
* string.
* @string: Input string (must...
Type: Posts; User: rmps
How about something like:
/**
* remstrchr - Remove all occurrences of character "c"
* from string "string". Returns the modified
* string.
* @string: Input string (must...
Here's another one. It uses the XOR trick, but you can use another temporary variable to swap characters.
char *revstr(char *const string)
{
register char *begin;
register char ...
So when fopen() fails, what does fclose(NULL)? :)
It depends what you mean by "standard". It isn't ANSI, but it conforms to POSIX standard...
If you have something as:
gets(buffer);
Replace it with:
fgets(buffer, sizeof buffer, stdin);
You have declared the "thepattern" member of "struct patterninput" as an array of chars ("char thepattern[MAX];") and the function "returns_pattern()" is declared as returning a char ("char...
int first_digit(int number)
{
if (number < 0)
number = -number;
while (number >= 10)
number /= 10;
return number;
}
Assuming that you're using unsigned int number as input and ASCII,
void
print_reverse_number(const unsigned int number)
{
const unsigned int quotient = number / 10;
...
Using gcc (so this isn't portable), you could use:
typedef struct {
UInt16 a;
UInt16 b;
UInt32 c;
. . .
} __attribute__ ((packed)) MyStruct;
So that is number 381654729.
Other numbers (that contains the 0 digit): 381654720 (already reported by itsme86), 783204165 and 801654723.
Now I left the code as an exercise for the reader. ;)
I'm assuming it is an ASCII string that only contains '0's and/or '1's.
char *
bitstrnot(char *const string)
{
register char *pointer;
static char *
erase(char *const string, const char c)
{
register char *src;
register char *dst;
for (src = dst = string; *src != '\0'; src++)
if...
It seems this is homework... Anyway:
unsigned int
unique_lower(const char *const string)
{
const char *pointer;
unsigned int count = 0U;
free() is used to free memory previously allocated with malloc()/calloc() functions.
text1[0] = '\0'; /* Or text1[0] = 0; */
does the trick. You could also clear all characters with:
...
If I did understand correctly, what you want is something along this:
#include <stdio.h>
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(*array))
int main(void)
{
const char *a = "some string ";
const char *b = "some other string";
char *c;
/* Allocate memory for both strings and string terminator ('\0'): */
if ((c = malloc(strlen(a) + strlen(b) + 1)) !=...