yesh i resloved the issue. it is due to file is generated by windows so it contain /r/n so now i created file in unix system , now it resolved my issue. but how we handle such situation
ashukasama
Posts
-
STL map in UNIX -
STL map in UNIXAbove code is working, But this code is not working
//Inclue files for libraries
#include <stdlib.h>
#include <ctype.h>
#include <iostream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <string>
#include <stdio.h>
#include <map>
#include <algorithm>using namespace std;
map <string, int> m1;
string tokenizeReturnFirst(const string& str,const char& delimiters)
{
string token;// skip delimiters at beginning. string::size\_type lastPos = str.find\_first\_not\_of(delimiters, 0); // find first "non-delimiter". string::size\_type pos = str.find\_first\_of(delimiters, lastPos); if( pos!=string::npos) { token = str.substr(lastPos, pos - lastPos); } else { token = str; } return token;
}
int main()
{
m1.insert(map <string, int> :: const_iterator::value_type("cd",0));
m1.insert(map <string, int> :: const_iterator::value_type("dir",0));
m1.insert(map <string, int> :: const_iterator::value_type("pwd",0));
m1.insert(map <string, int> :: const_iterator::value_type("echo",0));
m1.insert(map <string, int> :: const_iterator::value_type("help",0));
m1.insert(map <string, int> :: const_iterator::value_type("quit",0));
map <string, int> :: const_iterator m1_AcIter, m1_RcIter;
typedef pair <string, int> Int_Pair;
ifstream ifile( "test.bat");
if ( ifile.fail() )
{
fprintf(stderr, "Cannot open %s\n", "output_file");
return 0;
}while (!ifile.eof()) { string data\_string ; getline(ifile,data\_string); string command = tokenizeReturnFirst(data\_string,string::value\_type(' ')); //std::transform( command.begin(), command.end(), command.begin(), ::tolower ); cout<<"Searched string - "<<command <<endl; m1\_AcIter = m1.find(command); if(!command.empty()) { if(m1\_AcIter == m1.end()) { cout<<"Didn't find unix command - "<< data\_string<<endl ; } else { cout<<"SYSTEM - "<< data\_string.c\_str()<<endl; system(data\_string.c\_str()); } } }
-
STL map in UNIXI want to write shell programming in UNIX, alao i am new to unix. i have written very simple program for console ISSUE: I added some item in map as string int pair, now i am searching string read from commandline and i am unable to find it, but if i use same code with windows . i am able to do same. Code is as follows
//Inclue files for libraries
#include <stdlib.h>
#include <ctype.h>
#include <iostream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <ctime>
#include <string>
#include <stdio.h>
#include <map>
#include <algorithm>using namespace std;
map <string, int> m1;
int main(int argc, char* argv[])
{
m1.insert(map <string, int> :: const_iterator::value_type("cd",0));
m1.insert(map <string, int> :: const_iterator::value_type("dir",0));
m1.insert(map <string, int> :: const_iterator::value_type("pwd",0));
m1.insert(map <string, int> :: const_iterator::value_type("echo",0));
m1.insert(map <string, int> :: const_iterator::value_type("help",0));
m1.insert(map <string, int> :: const_iterator::value_type("quit",0));
map <string, int> :: const_iterator m1_AcIter, m1_RcIter;
typedef pair <string, int> Int_Pair;if(argc == 1) { cout<<"Please enter unix command.."; } else { string command; command = argv\[1\]; map <string, int> :: const\_iterator m1\_AcIter, m1\_RcIter; m1\_AcIter = m1.find(command); if(m1\_AcIter == m1.end()) { cout<<"Didn't find unix command - "<< command<<endl ; } else { system(command.c\_str()); } } map <string, int> :: iterator it; for ( it=m1.begin() ; it != m1.end(); it++ ) cout << (\*it).first << " => " << (\*it).second << endl; return 0;
}
now i am running this code ./a.out ls and i received following output
Didn't find unix command - ls cd =>; 0 dir =>; 0 echo =>; 0 help =>; 0 pwd =>; 0 quit =>; 0
but same code is working perfectly with windows. -
From C++ Windows Formsuse ShowDialog
-
Transferring arrays from C++ library to C# application -
OnMouseMove FlagsnFlags Indicates whether various virtual keys are down. This parameter can be any combination of the following values: MK_CONTROL Set if the CTRL key is down. MK_LBUTTON Set if the left mouse button is down. MK_MBUTTON Set if the middle mouse button is down. MK_RBUTTON Set if the right mouse button is down. MK_SHIFT Set if the SHIFT key is down.
-
ON_COMMAND_EX -
Creating ODBC Driver ( Link and good article Needed )Hi Guys, we have our own database and API. which is used by many application. we have some ODBC SQl interface to support odbc driver to export data in Excel and any application. I am able to understand the complte functionlity, but i am not much aware how OS will recognise odbc driver (may be using function ) i want some good article and good link on creating odbc driver with eg if possible thanks Guys
-
How to retrieve font size of a dialog box??CFont* font = pWnd->GetFont(); if (font) { LOGFONT lf; font->GetLogFont(&lf); } :)
-
How to retrieve font size of a dialog box??CFont* fn = GetdlgItem(ID of static :)Box)->GetFont( ) :)
-
Process ID from ThreadGetProcessIdOfThread(OpenThread( THREAD_ALL_ACCESS ,false ,thread id)) :) :)
-
Taskbarnotifierhave a look http://www.codeguru.com/Cpp/controls/statusbar/article.php/c5937/ Ashish K
-
How to egalise two stringss1 is CString then can use CompareNoCase Compare
-
how To make a mdi form? [modified]dear what you need is not clear ,:confused: because ur subject says you want to "make a mdi form?":sigh: please elaborate in more detail. :)
-
Enable/Disable Menuitems of MdiParent from MdiChildyou are welcome :)
-
how To make a mdi form? [modified]make yo:)ur child as a IsMdiContainer as true , it will become mdi child Ashish Kasma
-
Enable/Disable Menuitems of MdiParent from MdiChildwhere you launch it frmSignOn frm = new frmSignOn(); frm. MdiParent = this; frm.Show(); and at the time of private void frmSignOn_Load(object sender, System.EventArgs e) { frmMain fM = (frmMain)this.MdiParent; fM.menuItem1.Enabled = false; } :)
-
Enable/Disable Menuitems of MdiParent from MdiChildyeah dear :) Ashu Ashish Kasama
-
Enable/Disable Menuitems of MdiParent from MdiChilduse this.Parent Form2 fr2 = (Form2)this.Parent; and make menuItem1 public but better approach is to make function in MDI parent to enable and disable menu item and call function in child using fr2. :)
-
user's current wallpaperMicrosoft.Win32 is used for accessing the registry, while System.Runtime.InteropServices is used for accessing the unmanaged user32.dll. Next comes the preparation of the unmanaged function SystemParametersInfo() - this should be located at the top of the:) class definition:
[DllImport("user32.dll", CharSet = CharSet.Auto)] static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
First thing is to retrieve the current desktop wallpaper, and to do that we don't need to use a function, but simply read a value in the Windows registry. Let's create the method for that:private string GetCurrentWallpaper() { // The current wallpaper path is stored in the registry at HKEY_CURRENT_USER\\Control Panel\\Desktop\\WallPaper RegistryKey rkWallPaper = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", false); string WallpaperPath = rkWallPaper.GetValue("WallPaper").ToString(); rkWallPaper.Close(); // Return the current wallpaper path return WallpaperPath; }
Next comes the definition of the method that actually sets the wallpaper, Additional for you . And it's only a few lines of code: private void SetWallpaper(string WallpaperLocation, int WallpaperStyle, int TileWallpaper) { // Sets the actual wallpaper SystemParametersInfo(20, 0, WallpaperLocation, 0x01 | 0x02); // Set the wallpaper style to streched (can be changed to tile, center, maintain aspect ratio, etc. RegistryKey rkWallPaper = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true); // Sets the wallpaper style rkWallPaper.SetValue("WallpaperStyle", WallpaperStyle); // Whether or not this wallpaper will be displayed as a tile rkWallPaper.SetValue("TileWallpaper", TileWallpaper); rkWallPaper.Close(); } :)