Hi,
Thank you all, for participating.
Salem, Thankyou for pointing that out, and pointing me in the direction of the thread, I was wondering why it always returns 'Doesn't match' with -
Code:
#include <stdio.h>
int main()
{
FILE *fd=popen("md5sum /etc/passwd","r");
char buf[128];
char buf2[] = "6aad283ce232c415b61e1d8c190c2b38 /etc/passwd";
if(fd) {
while(fgets(buf,128,fd))
if(strcmp(buf,buf2)==0)
puts("\nMatches\n\n");
else puts("\nDoesn't match\n\n");
}
pclose(fd);
}
but i am unable to incorporate the example(s) into my program, or should i say i dont know how to. Here is how Ive tried to use it:
Code:
#include <stdio.h>
int main()
{
FILE *fd=popen("md5sum /etc/passwd","r");
char buf[128];
char buf2[] = "6aad283ce232c415b61e1d8c190c2b38 /etc/passwd";
char *p = strchr(buff, '\n'); if(p!=null) *p='\n';
if(fd) {
while(fgets(buf,128,fd))
if(strcmp(buf,buf2)==0)
puts("\nMatches\n\n");
else puts("\nDoesn't match\n\n");
}
pclose(fd);
}