Search:

Type: Posts; User: rmps

Search: Search took 0.01 seconds.

  1. Thread: Remove Spaces?

    by rmps
    Replies
    15
    Views
    8,961

    How about something like: /** *...

    How about something like:



    /**
    * remstrchr - Remove all occurrences of character "c"
    * from string "string". Returns the modified
    * string.
    * @string: Input string (must...
  2. Replies
    19
    Views
    2,835

    Here's another one. It uses the XOR trick, but...

    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 ...
  3. Thread: stdlib.h system()

    by rmps
    Replies
    8
    Views
    2,505

    So when fopen() fails, what does fclose(NULL)? :)

    So when fopen() fails, what does fclose(NULL)? :)
  4. Replies
    12
    Views
    5,626

    It depends what you mean by "standard". It isn't...

    It depends what you mean by "standard". It isn't ANSI, but it conforms to POSIX standard...
  5. Replies
    9
    Views
    4,330

    If you have something as: gets(buffer); ...

    If you have something as:


    gets(buffer);

    Replace it with:


    fgets(buffer, sizeof buffer, stdin);
  6. You have declared the "thepattern" member of...

    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...
  7. Thread: simple c question

    by rmps
    Replies
    8
    Views
    1,591

    int first_digit(int number) { if...

    int first_digit(int number)
    {
    if (number < 0)
    number = -number;

    while (number >= 10)
    number /= 10;

    return number;
    }
  8. Assuming that you're using unsigned int number as...

    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;
    ...
  9. Replies
    8
    Views
    3,139

    Using gcc (so this isn't portable), you could...

    Using gcc (so this isn't portable), you could use:



    typedef struct {
    UInt16 a;
    UInt16 b;
    UInt32 c;
    . . .
    } __attribute__ ((packed)) MyStruct;
  10. Thread: C programming

    by rmps
    Replies
    20
    Views
    3,305

    So that is number 381654729. Other numbers (that...

    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. ;)
  11. Replies
    3
    Views
    1,420

    I'm assuming it is an ASCII string that only...

    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;
  12. Replies
    8
    Views
    1,730

    static char * erase(char *const string, const...

    static char *
    erase(char *const string, const char c)
    {
    register char *src;
    register char *dst;


    for (src = dst = string; *src != '\0'; src++)
    if...
  13. Replies
    5
    Views
    2,504

    It seems this is homework... Anyway: ...

    It seems this is homework... Anyway:



    unsigned int
    unique_lower(const char *const string)
    {
    const char *pointer;
    unsigned int count = 0U;
  14. Thread: free command

    by rmps
    Replies
    2
    Views
    1,753

    free() is used to free memory previously...

    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:

    ...
  15. Replies
    3
    Views
    1,159

    If I did understand correctly, what you want is...

    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)
    {
  16. Thread: strcat

    by rmps
    Replies
    7
    Views
    1,968

    const char *a = "some string "; const char *b =...

    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)) !=...
Results 1 to 16 of 16