hello,
I need a help . how to parse a string in c.
also, how to get the avilable commands by putting first letter and click tab key.
i.e., like linux,
when i put "l", and click tab, it show ls,lockfile, locat etc.
how to do it in C?.
Printable View
hello,
I need a help . how to parse a string in c.
also, how to get the avilable commands by putting first letter and click tab key.
i.e., like linux,
when i put "l", and click tab, it show ls,lockfile, locat etc.
how to do it in C?.
have you searched the forum? http://cboard.cprogramming.com/searc...earchid=597083
(and maybe google http://www.google.co.il/search?hl=ru&q=parse+string+C)?
Have you tried the some of the results?
Encountered problems?
Then post your attemp and ask question about the code.
Umm . . . vart, your first link turns up no hits. ;)
That's more complicated. You'd have to get a list of the commands (perhaps by listing all the files in a directory, and discarding the files that aren't executable), then search for files starting with your string. (I would definitely sort the list in this case.)Quote:
also, how to get the avilable commands by putting first letter and click tab key.
i.e., like linux,
when i put "l", and click tab, it show ls,lockfile, locat etc.
how to do it in C?.
So, look up opendir(), readdir(), and closedir() for listing all the files in a directory. Also see this FAQ entry: http://faq.cprogramming.com/cgi-bin/...&id=1044780608
Then look up some sorting algorithms, perhaps the insertion sort.
Then parse the list of files with strcmp(), finding the first and last match, perhaps making use of binary searching.
Or just execute this command:
:)Code:system("ls -1F start* | grep '*$'");
Ups - it seems to be timed out...Quote:
Originally Posted by dwks
Haven't noted that instead of the search terms it uses search id...
parse string - that what I've searched
Also forgot to edit the google serch link to remove the hl=ru