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. problem with undeclared identifire in my IP parser project

problem with undeclared identifire in my IP parser project

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++database
2 Posts 2 Posters 0 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.
  • R Offline
    R Offline
    Reza Shademani
    wrote on last edited by
    #1

    hi mates; look at here at first : //stripdec.h #pragma once #ifndef ipaddressing_strIPdec #define ipaddressing_strIPdec #include "stdafx.h" using namespace std; using std::string; typedef unsigned long ulong; // strIPDec in order to deploying A.B.C.D strandard IP address from plain // string a.b.c.d namespace stripdec { class StrIPGet { public : StrIPGet();//constructor string get();//getting input string a.b.c.d void findindex();//finding index of each '.' in the string void setseg();//now we have A.B.C.D which each segemnt is in digit form. private: string _inputstr; short inpindex[3]; string segment[4]; }; class StrToDec { public: ulong conv(string& _segstr); }; } // #endif //////////////// //stripdec.cpp // strIPdec.cpp : Defines the entry point for the DLL application. // #include "stripdec.h" #include "stdafx.h" using namespace std; using namespace stripdec; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } //start //------------------------------------------ string StrIPGet::get() { int count=0; do { getline(cin,_inputstr,' '); int j = _inputstr.find('.'); // While not at the end of the string: while(j != _inputstr.npos) { count++ //find the next '.' j = _inputstr.find('.', j); } if (count != 3)cout<<"invalid IP address ,try again."<<"\n"; } while (count != 3) //input is plain a.b.c.d along with error recovery. } //------------------------------------------ StrIPGet::StrIPGet() { inputstr.clear();//init...clearing an input string } //------------------------------------------ void StrIPGet::findindex() { for(j=0;j<=2;j++) { inpindex[j]=_inputstr.find('.',j); } } //------------------------------------------- void StrIPGet::setseg() { segment[0]=_inputstr.substr(0,inpindex[0]-0); segment[1]=_inputstr.substr(inpindex[0],inpindex[1]-inpindex[0]); segment[2]=_inputstr.substr(inpindex[1],inpindex[2]-inpindex[1]); segment[3]=_inputstr.substr(inpindex[2],input.end-inpindex[2]); } //------------------------------------------- ulong StrToDec::conv(string& _segstr) { return strtoul(_segstr); } errors : ///////////////////// e:\codes\IP_Addressing_solution\April11 ,2003\strIPdec\stripdec.cpp(25): error C2065: '_inputstr' : undeclared identifier e:\codes\IP_Addressing_solution\April11 ,2003\strIPdec\stripdec.cpp(26): error C2228: left of '.find' m

    H 1 Reply Last reply
    0
    • R Reza Shademani

      hi mates; look at here at first : //stripdec.h #pragma once #ifndef ipaddressing_strIPdec #define ipaddressing_strIPdec #include "stdafx.h" using namespace std; using std::string; typedef unsigned long ulong; // strIPDec in order to deploying A.B.C.D strandard IP address from plain // string a.b.c.d namespace stripdec { class StrIPGet { public : StrIPGet();//constructor string get();//getting input string a.b.c.d void findindex();//finding index of each '.' in the string void setseg();//now we have A.B.C.D which each segemnt is in digit form. private: string _inputstr; short inpindex[3]; string segment[4]; }; class StrToDec { public: ulong conv(string& _segstr); }; } // #endif //////////////// //stripdec.cpp // strIPdec.cpp : Defines the entry point for the DLL application. // #include "stripdec.h" #include "stdafx.h" using namespace std; using namespace stripdec; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { return TRUE; } //start //------------------------------------------ string StrIPGet::get() { int count=0; do { getline(cin,_inputstr,' '); int j = _inputstr.find('.'); // While not at the end of the string: while(j != _inputstr.npos) { count++ //find the next '.' j = _inputstr.find('.', j); } if (count != 3)cout<<"invalid IP address ,try again."<<"\n"; } while (count != 3) //input is plain a.b.c.d along with error recovery. } //------------------------------------------ StrIPGet::StrIPGet() { inputstr.clear();//init...clearing an input string } //------------------------------------------ void StrIPGet::findindex() { for(j=0;j<=2;j++) { inpindex[j]=_inputstr.find('.',j); } } //------------------------------------------- void StrIPGet::setseg() { segment[0]=_inputstr.substr(0,inpindex[0]-0); segment[1]=_inputstr.substr(inpindex[0],inpindex[1]-inpindex[0]); segment[2]=_inputstr.substr(inpindex[1],inpindex[2]-inpindex[1]); segment[3]=_inputstr.substr(inpindex[2],input.end-inpindex[2]); } //------------------------------------------- ulong StrToDec::conv(string& _segstr) { return strtoul(_segstr); } errors : ///////////////////// e:\codes\IP_Addressing_solution\April11 ,2003\strIPdec\stripdec.cpp(25): error C2065: '_inputstr' : undeclared identifier e:\codes\IP_Addressing_solution\April11 ,2003\strIPdec\stripdec.cpp(26): error C2228: left of '.find' m

      H Offline
      H Offline
      Hans Ruck
      wrote on last edited by
      #2

      Probably in strIPdec.cpp you should have

      #include "stdafx.h"
      #include "stripdec.h"

      rechi

      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