Thread: Strcmp

  1. #16
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by jeffcobb View Post
    Look up stat() and friends if you are on a *NIX OS; POSIX has a whole raft of ops that can answer these questions...
    and also on Windows. Although Microsoft prefers to call it _stat() instead.
    Most of those POSIX functions start with _ on Windows.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  2. #17
    Registered User
    Join Date
    Mar 2009
    Posts
    112
    Code:
    string* getFname()
    		{
    		
    			if((hfile=_findfirst("C:/tr1/*.txt",&c_file))==-1)
    			{}
    			
    			else
    			{
                    int position=0;
    				str[0]=c_file.name;
    				position++;
    			
    				while(_findnext(hfile,&c_file)==0);
    				{				
    					str[position]=c_file.name;
    					position++;
    				}
    			}
    			return str;
    		}
    this functions searches for all the text files in the particular folder and returns their name in string pointer.

    Code:
    	int manipulation()	const
    		{	
    			fstream  my_file;			string line;
    			string::size_type found;	
    			
    			my_file.open ((file::getFname()).c_str());
    			{
    				if (my_file.is_open())
    				{
    					while ( getline(my_file,line) )
    					{
    						found=line.find(word); 
    						if (found != string::npos){		return found;			 }
    						/*if (found == string::npos){	cout<<"NOT found"<<endl; }*/
    					}
    					my_file.close();
    				}
    				else 	{ cout<<"File not opened";	}
    			}		
    		}
    this files then uses the name of the file and do the manipulations i.e searches for the word in the file . I dont know how to deal with the pointers .The higlighted part of code is giving me errors.
    cannot convert 'this' pointer from 'const FileManipulator' to 'file &'

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fucntion returns -1, Why?
    By Taper in forum C Programming
    Replies: 16
    Last Post: 12-08-2008, 06:30 PM
  2. help with switch statement
    By agentsmith in forum C Programming
    Replies: 11
    Last Post: 08-26-2008, 04:02 PM
  3. problem with strings
    By agentsmith in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 12:07 PM
  4. help with strcmp
    By blork_98 in forum C Programming
    Replies: 8
    Last Post: 02-21-2006, 08:23 PM
  5. strcmp
    By kryonik in forum C Programming
    Replies: 9
    Last Post: 10-11-2005, 11:04 AM