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?.
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.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
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.)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 '*$'");
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Ups - it seems to be timed out...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
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler