Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. NEW AT FUNCTIONS, PLEASE HELP, URGETNT

NEW AT FUNCTIONS, PLEASE HELP, URGETNT

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studiodesign
3 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashrafak
    wrote on last edited by
    #1

    THE QUESTION REQUIRES US TO DESIGN A FUNCTION AS MENTIONED BELOW, AND EVERYTIME I DEBUG THE PROGRAM, IT GIVES ME ONLY ONE ERROR WHICH IS MENTIONED RIGHT AT TEH BOTTOM OF THE PAGE. //Purpose::TO CONVERT A GIVEN SIX DIGIT INTEGER TO DATE FORMAT (dd/mm/yyyy)AND CHECK Y2K COMPLIANCE #include "stdafx.h" #using using namespace System; int D,DD,MM,YY; void separateDate(int *temp,int *DD,int *MM,int *YY) { *DD=*temp/10000; *MM=(*temp%10000)/100; *YY=(*temp%10000)%100; do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*DD<1 || *DD>31); do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*MM<1 || *MM>12); if (*YY<=36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/20{2}",*DD.ToString(),*MM.ToString(),*YY.ToString()); //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type } else if (*YY>36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/19{2}",*DD.ToString(),*MM.ToString(),*YY.ToString()); //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type } } int _tmain() { Console::WriteLine(S"*******************************************************************"); Console::WriteLine(S"\t\tDATE FORMAT"); Console::WriteLine(S"*******************************************************************"); void separateDate(int *temp, int *DD, int *MM, int *YY); Console::Write(S"\nENTER THE DATE (SIX DIGIT POSITIVE INTEGER): "); D=D.Parse(Console::ReadLine()); separateDate(&D,&DD,&MM,&YY); Console::ReadLine(); return 0; } //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type I HAVE ALSO MENTIONED THE ERROR IN THE LINES IT OCCURS, PLEASE HELP, AM IN A TIGHT SPOT!! THANKS

    P C 2 Replies Last reply
    0
    • A ashrafak

      THE QUESTION REQUIRES US TO DESIGN A FUNCTION AS MENTIONED BELOW, AND EVERYTIME I DEBUG THE PROGRAM, IT GIVES ME ONLY ONE ERROR WHICH IS MENTIONED RIGHT AT TEH BOTTOM OF THE PAGE. //Purpose::TO CONVERT A GIVEN SIX DIGIT INTEGER TO DATE FORMAT (dd/mm/yyyy)AND CHECK Y2K COMPLIANCE #include "stdafx.h" #using using namespace System; int D,DD,MM,YY; void separateDate(int *temp,int *DD,int *MM,int *YY) { *DD=*temp/10000; *MM=(*temp%10000)/100; *YY=(*temp%10000)%100; do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*DD<1 || *DD>31); do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*MM<1 || *MM>12); if (*YY<=36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/20{2}",*DD.ToString(),*MM.ToString(),*YY.ToString()); //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type } else if (*YY>36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/19{2}",*DD.ToString(),*MM.ToString(),*YY.ToString()); //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type } } int _tmain() { Console::WriteLine(S"*******************************************************************"); Console::WriteLine(S"\t\tDATE FORMAT"); Console::WriteLine(S"*******************************************************************"); void separateDate(int *temp, int *DD, int *MM, int *YY); Console::Write(S"\nENTER THE DATE (SIX DIGIT POSITIVE INTEGER): "); D=D.Parse(Console::ReadLine()); separateDate(&D,&DD,&MM,&YY); Console::ReadLine(); return 0; } //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type I HAVE ALSO MENTIONED THE ERROR IN THE LINES IT OCCURS, PLEASE HELP, AM IN A TIGHT SPOT!! THANKS

      P Offline
      P Offline
      Pablo Hernandez Valdes
      wrote on last edited by
      #2

      The problem is that the int C++ type is used, and it isn't a struct/class. You should use the System::Int32 type if you want to use the .ToString method.:) #include "stdafx.h" #using using namespace System; System::Int32 D,DD,MM,YY; void separateDate(System::Int32 *temp,System::Int32 *DD,System::Int32 *MM,System::Int32 *YY) { *DD=*temp/10000; *MM=(*temp%10000)/100; *YY=(*temp%10000)%100; do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*DD<1 || *DD>31); do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*MM<1 || *MM>12); if (*YY<=36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/20{2}",(*DD).ToString(),(*MM).ToString(),(*YY).ToString()); } else if (*YY>36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/19{2}",(*DD).ToString(),(*MM).ToString(),(*YY).ToString()); } } int _tmain() { Console::WriteLine(S"*******************************************************************"); Console::WriteLine(S"\t\tDATE FORMAT"); Console::WriteLine(S"*******************************************************************"); void separateDate(System::Int32 *temp, System::Int32 *DD, System::Int32 *MM, System::Int32 *YY); Console::Write(S"\nENTER THE DATE (SIX DIGIT POSITIVE INTEGER): "); D=D.Parse(Console::ReadLine()); separateDate(&D,&DD,&MM,&YY); Console::ReadLine(); return 0; } Pablo Hernandez Valdes

      1 Reply Last reply
      0
      • A ashrafak

        THE QUESTION REQUIRES US TO DESIGN A FUNCTION AS MENTIONED BELOW, AND EVERYTIME I DEBUG THE PROGRAM, IT GIVES ME ONLY ONE ERROR WHICH IS MENTIONED RIGHT AT TEH BOTTOM OF THE PAGE. //Purpose::TO CONVERT A GIVEN SIX DIGIT INTEGER TO DATE FORMAT (dd/mm/yyyy)AND CHECK Y2K COMPLIANCE #include "stdafx.h" #using using namespace System; int D,DD,MM,YY; void separateDate(int *temp,int *DD,int *MM,int *YY) { *DD=*temp/10000; *MM=(*temp%10000)/100; *YY=(*temp%10000)%100; do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*DD<1 || *DD>31); do { Console::WriteLine(S"\nEnter a Valid Date: "); } while (*MM<1 || *MM>12); if (*YY<=36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/20{2}",*DD.ToString(),*MM.ToString(),*YY.ToString()); //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type } else if (*YY>36) { Console::WriteLine(S"\nTHE DATE IS: {0}/{1}/19{2}",*DD.ToString(),*MM.ToString(),*YY.ToString()); //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type } } int _tmain() { Console::WriteLine(S"*******************************************************************"); Console::WriteLine(S"\t\tDATE FORMAT"); Console::WriteLine(S"*******************************************************************"); void separateDate(int *temp, int *DD, int *MM, int *YY); Console::Write(S"\nENTER THE DATE (SIX DIGIT POSITIVE INTEGER): "); D=D.Parse(Console::ReadLine()); separateDate(&D,&DD,&MM,&YY); Console::ReadLine(); return 0; } //h:\Visual Studio Projects\Y2k\Y2K.cpp(28): error C2228: left of '.ToString' must have class/struct/union type I HAVE ALSO MENTIONED THE ERROR IN THE LINES IT OCCURS, PLEASE HELP, AM IN A TIGHT SPOT!! THANKS

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        People are doing beginner courses in MC++ now ? What a travesty.... By the way, PLEASE DON'T YELL !!!! Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups