DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Search File or Folders

  1. #1
    Join Date
    May 2007
    Posts
    843

    Search File or Folders

    Hello all respective expert programmer, i totally a newbie in programming.

    I have wrote a program that compress a text file using run length encoding algorithm but i haven't succeed.

    I not very understand this tutorial.

    Can anyone tell me the algorithm ?

    Moreover, i also have another question about how to search a file or folder enter by user because i need to validate the file path is exist.

    Below is my program :

    Code:
    #include<iostream>
    #include<vector>
    #include<fstream>
    #include<string>
    
    using namespace std;
    
    // ----------------------------------------
    
    void draw();
    
    void filePath(vector<string> &);
    void validateFilePath();
    
    void compress();
    void decompress();
    
    
    // ----------------------------------------
    int main(int argc, char *argv[])
    {
    	string temp("asd");
    	ifstream inputFile;  // Read from file
    	vector<string> userFilePath(1, temp);
    
    
    	draw();
    	filePath(userFilePath);
    
    	return 0;
    }
    // -----------------------------------------
    void draw()
    {
    	int loop;
    
    	cout << "\n\n\n\t\t";
    
    	for (loop=0;loop<60;++loop)
    	{
    		cout << "-";
    	}
    	
    	cout << "\n\n\t\t\t  Welcome to newly Run Length Encoding Program";
    	cout << "\n\n\n\t\t";
    	for (loop=0;loop<60;++loop)
    	{
    		cout << "-";
    	}
    	cout << "\n\n\n\n";
    	
    }
    // ----------------------------------------
    void filePath(vector<string> &userFilePath)
    {
    	string temp;
    
    	cout << "\n\n\t\t\t\tEnter a file path : ";
    	getline(cin, temp);
    
    	userFilePath.push_back(temp);
    	
    }
    // ------------------------------------------
    void validateFilePath(vector<string> &userFilePath)
    {
    	
    }
    // ------------------------------------------

    A billion thanks for your help.

    Your help is greatly appreciated by me and others.
    Last edited by Peter_APIIT; 01-20-2008 at 05:03 AM.

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Does this work for you?
    Code:
    int main(int argc, char *argv[])
    {
      printf("%s\n", argv[0]);
      return 0;
    }

  3. #3
    Join Date
    Dec 2003
    Posts
    3,366
    run length encoding is very simple peter. You count the number of times you have an item and write the item followed by the number. You can do this bitwise, bytewise, or otherwise(ok bad pun). You can decide how many bytes to use for the number field as well (1, or 2 make the most sense unless you have enormous data files (gigabytes)).

    So if you had a file with the text
    aaaaaaaaaaaabccdddddddddd you could RLE it to
    a12b1c2d10 (of course as bytes the numbers would not look like this, this is the concept not actual data)

    Notice that b1 takes up MORE space than b, and C2 takes up the same space. So to get anything from RLE, your data should have very few single happening pieces of data and many many of the three + sequences.

  4. #4
    Join Date
    May 2007
    Posts
    843
    You can do this bitwise, bytewise, or otherwise(ok bad pun). You can decide how many bytes to use for the number field as well (1, or 2 make the most sense

    I understand the rest but not this sentence. Sorry for my stupidity.

    A billion thanks for your help.

Similar Threads

  1. How to pass string to concatenate routine.
    By haran415 in forum VB Classic
    Replies: 4
    Last Post: 04-15-2007, 10:40 AM
  2. How Do I Display Folders In A File List Box
    By Code_Writer in forum VB Classic
    Replies: 5
    Last Post: 08-14-2005, 11:58 PM
  3. NullPointerException when reading text file
    By Andrew McLellan in forum Java
    Replies: 3
    Last Post: 05-09-2001, 05:34 PM
  4. developers needed
    By Patrick Lauber in forum enterprise.announcements
    Replies: 0
    Last Post: 03-07-2001, 11:49 AM
  5. Replies: 3
    Last Post: 05-31-2000, 10:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center