directory - Finding a text file in Ubuntu directories -


i have program , goal finding text file programs in linux, finds files *.*. please me find problem of code?

#include<stdio.h> #include<stdlib.h>  int main() {     char str[256], str2[256], buf[256];      strcpy(str,"find -name ");     strcpy(str2,"'*.txt'");     sprintf(buf, "/bin/sh -c %s %s", str,str2);     system(buf);     return 0; } 

find if called without location search in, 'execution location sensitive' meaning if execute program / (root) /home/you/myprogram/./executable, program start searching directories on system. if instead in /home/you/myprogram, example contained textfile called test.txt find test.txt running ./executable.

i suggest either using program behavior in mind, or introducing parameter find, specifies location search in. further information see man find.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -