LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2006, 12:58 AM   #1
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Rep: Reputation: 15
Question Similar code for c


Without using shell commands(using system or popen) , can u get inode number,modification time in c. is there any function in c for this??

Thanks in advance.
 
Old 01-17-2006, 01:23 AM   #2
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
Yes, there is: stat()
 
Old 01-17-2006, 01:57 AM   #3
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Original Poster
Rep: Reputation: 15
can u just tell me how to use it..coz i have tried it and its not working..
if possible write any example for this..plz..


thanks in advance.
 
Old 01-17-2006, 02:05 AM   #4
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Original Poster
Rep: Reputation: 15
when you run the following command on shell--

stat -c %y filename

then it gives the then modification time similar to following...

year-day-month modification time...

when i used the stat() function in c program and tried to get the modification time then it gave me one big number...( probably in seconds..)

can i get the output similar to that one produced in shell script but using
stat() in c ?
 
Old 01-17-2006, 03:06 AM   #5
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
A quick test program:
Code:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>


int main(int argc, char *argv[])
{
  struct stat tmp;
  char buffer[50];
  
  stat(argv[1], &tmp);
  strftime(buffer, 50, "Modification time: %Y-%m-%d %T %z\n", localtime(&(tmp.st_mtime)));
  puts(buffer);
}

Last edited by Harmaa Kettu; 01-17-2006 at 03:07 AM.
 
Old 01-17-2006, 04:25 AM   #6
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Original Poster
Rep: Reputation: 15
Question

thanx for reply...

What is C function for calculating MD5SUM without using shell script...
We dont want to use system and popen.Is there any direct C function for calculating MD5SUM..


Thanks in advance..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 02:14 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
How can I type ASCII codes in a similar way like the old ALT+<code> way? pujolasdf Linux - Software 0 07-17-2005 03:22 PM
Editing buttons (quote, code etc.) add the code to the end vharishankar LQ Suggestions & Feedback 2 09-13-2004 09:32 AM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 11:16 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration