library function

This is a discussion on library function within the C Programming forums, part of the General Programming Boards category; Hi, anyone know of a function already written in C, that accepts a char *, returns a char * and ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    93

    library function

    Hi,

    anyone know of a function already written in C, that accepts a char *, returns a char * and does the following

    input similar to 20030908.00
    output required 08092003 [i.e., ddmmyyyy]


    tia,

  2. #2
    Visionary Philosopher Sayeh's Avatar
    Join Date
    Aug 2002
    Posts
    212
    Why not write your own? It's trivial.
    It is not the spoon that bends, it is you who bends around the spoon.

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    93
    um thanks

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Try this.
    Code:
    #include <stdio.h>
    #include <string.h>
    
    int main(void)
    {
       char a[20] = "20030908.00";
       char b[20] = "";
    
       strncpy( b,a+6,2 );
       strncat( b,a+4,2 );
       strncat( b,a,4 );
       printf( "%s\n",b );
    
       return 0;
    }

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    93
    ty swoopy

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  3. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  4. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 09:18 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21