Giter Club home page Giter Club logo

c-auto-complete-suggestions's Introduction

C-auto-complete-suggestions

This C program generates auto-complete suggestions similar to the behavior of Bash when beginning to type a command and pressing the "Tab" key. The program reads all file names in a user-provided directory and stores them in a data structure known as a Trie. The Trie is implemented using a linked list structure. Each letter of the alphabet has its own linked list within the Trie, storing filenames that start with that letter in alphabetical order.

The program allows the user to enter the beginning of a filename they are interested in. Upon pressing enter, all filenames that match that prefix will be printed in alphabetical order. The program will continue to prompt for filename prefixes until an empty string is entered.

To implement this functionality, the program includes the following functions:

  • createTrieNode(): Creates a new Trie node and initializes its fields.
  • insert(): Inserts a new word into the Trie recursively.
  • isEndOfWord(): Checks if a Trie node is the end of a word.
  • print(): Prints all filenames that match a given prefix in alphabetical order.
  • search(): Searches for a word in the Trie.
  • autosuggestion(): Provides auto-complete suggestions based on the entered prefix.

Additionally, the program includes the following helper functions:

  • letterNumb(): Handles special characters and converts uppercase letters to lowercase ASCII values.
  • invert_case(): Converts uppercase letters in filenames to lowercase.

To use the program, the user needs to provide the full path of the directory containing the files they want to autocomplete. The program then reads the filenames from that directory and constructs the Trie. The user can then enter prefixes of filenames to get auto-complete suggestions.

Please note that this program does not use any pre-existing C library functions for implementing the Trie. It is a manual implementation of the Trie data structure.

Sample Interaction

$ ./filecomplete
 
Enter a folder name: /usr/bin
> zi

Files starting with zi in /usr/bin:
zip 
zipcloak 
zipgrep 
zipinfo 
zipnote 
zipsplit 

> zipc
Files starting with zipc in /usr/bin:

zipcloak

c-auto-complete-suggestions's People

Contributors

umangptl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.