Thread: Convert String to time

  1. #1
    Registered User
    Join Date
    Nov 2007
    Location
    Singapore
    Posts
    24

    Convert String to time

    Hi, i have a problem over here..

    I am doing C programming on Visual Studio 2005, Console Application..

    I know that this can be done, but however, the compiler does not recognize some methods and my project is unable to build..

    Code:
    GetInformation.C
    /* Author: 054094F
    Nanyang Polytechnic Singapore
    Visual Studio 8.0
    */
    
    		printf("Enter date of birth: (DDMMYYYY) ");
    		gets(dob);
    		if (strptime(dob, "%d%m%Y", &tm) == NULL)
    			
    			printf("Invalid date please try again");
    
    		else	
    			printf("year: %d; month: %d; day: %d;\n", tm.tm_year, tm.tm_mon, tm.tm_mday);
    my error lies here
    Error 20 error LNK2001: unresolved external symbol _strptime getinformation.obj

    Error 21 fatal error LNK1120: 1 unresolved externals C:\Documents and Settings\User\My Documents\NYP Assignments\Year3 Sem2\IT3784 - C, Linux\054094F_Week5_ASSN\Debug\054094F_Week5_ASSN. exe
    Can anyone help?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Don't EVER use gets().

    strptime, it appears, is not part of the Microsoft library set.

    You may be able to find source for strptime in Linux or NetBSD C library source code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Location
    Singapore
    Posts
    24
    erm is there an alternative way to do this in visual studio?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It would appear that there is no such function.

    http://msdn2.microsoft.com/en-gb/lib...9h(VS.80).aspx

    You may try this NetBSD C library implementation. It probably requires SOME adjustment to compile in a Windows environment, but I expect it to only be small work.

    http://cvsweb.netbsd.org/bsdweb.cgi/...ime.c?rev=HEAD

    I got the NetBSD link from here:
    http://forums.microsoft.com/MSDN/Sho...97390&SiteID=1

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to convert string into LPCWSTR
    By krishnampkkm in forum C++ Programming
    Replies: 2
    Last Post: 06-15-2009, 06:02 AM
  2. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  3. The space time continueimnms mm... (rant)
    By Jeremy G in forum A Brief History of Cprogramming.com
    Replies: 32
    Last Post: 06-27-2004, 01:21 PM
  4. inputting time in separate compilation
    By sameintheend01 in forum C++ Programming
    Replies: 6
    Last Post: 03-13-2003, 04:33 AM
  5. How to decrease a time string by a given value
    By Ruchikar in forum C Programming
    Replies: 3
    Last Post: 04-11-2002, 12:08 PM