Results 1 to 8 of 8

Thread: Starting out in VC++ need help!

  1. #1

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136

    Starting out in VC++ need help!

    I get an error on line 19 in this code. The error is "C2228: left of '.tm_sec' must have class/struct/union type"

    Code:
    #include "stdafx.h"
    #include <iostream.h>
    #include "string.h"
    #include "time.h"
    
    int main()
    {
    	tm * x;
    	int sec;
    		
    	while (1==1)
    	{
    	
    		_getsystime(x);
    		
    		sec=x.tm_sec;
    		cout<<sec;
    	}
    
    	return 0;
    }
    What's wrong?
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Yes, but the most commonly used is "->"
    Baaaaaaaaah

  3. #3

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136
    Now I get an illegal operation error when I try to run it! It compiles fine tho
    BTW, Thanks for all your help

    Member of the anti-gay cross-dressing trans-species wolves alliance.

  4. #4
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    hmmm...First off, what is that "stdafx.h" header file for? If that is the only code you have in your whole project then you don't need this file. And for me, it is working. It is writting the "current seconds" in an endless loop

    If you have any other code then check that because this given code is working fine
    Baaaaaaaaah

  5. #5
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Make this
    Code:
    #include "string.h"
    #include "time.h"
    Code:
    #include <string.h>
    #include <time.h>
    The stdafx.h is included by VC++ if you chose simple console app. Choose an empty project and add a cpp file.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Is it only version 6 that adds its own stdafx.h file? I use something similar for large projects but call it stdpch.h/stdpch.cpp instead so I know it's for the precompiled headers rather than MFC
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yeah, it's actually just to make things a little bit simpler for the vc++ developers (not the users ) because they can always use "stdafx". Does not make sense, but they seem to see VC++ mainly as a tool to develop MFC Apps. I'd think too, that "stdpch" is a better name, but I don't like it in general, because you have to include the file in every source file you have.

    But what'cha (spelling???????) gonnado... Big bad richmond guy has more power

    All the buzzt
    CornedBee

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    He has the power, but I have the intelligence

    I don't have a problem with MFC when it's required...it's just I don't really like it and don't see why you should use it for most programs.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width