top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

how can I change the timestamp while creating a binary/text file in C ? I have used Windows API but that is little slow.

+2 votes

I am creating 500 binary files with one minute old time stamp. I am using windows API but it's very slow, so how can I improve the performance.

posted Nov 22, 2014 by Sunil Kumar Patro

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Assume your machine is Linux the you have following option -

$ touch -t [[CC]YY]MMDDhhmm[.SS]

CC – Specifies the first two digits of the year
YY – Specifies the last two digits of the year. 
MM – Specifies the month
DD – Specifies the date
hh – Specifies the hour
mm – Specifies the minute
SS – Specifies the seconds
For example:

$ touch -a -m -t **********.09 <yourfile>

So you can call the above command from the system statement in the C.

Now coming to the windows, in Windows you have following two API for the same purpose -

Let me know if you still have some issue.

answer Nov 23, 2014 by Salil Agrawal
Similar Questions
+2 votes

Lets say I have a file 1.c.


If I compile this using, cc 1.c i will get an executable i.e. a.out
If I run this it will be in infinite loop, while this process is running I am able to delete a.out

Where in same case if I start some movie/video and then if I try to delete it then i will not be allowed to.

Why ?

0 votes

I have a problem with an already committed file into my repo. This git repo was converted from svn to git some years ago. Last week I have change some lines in a file and I saw in the diff that it is marked as binary (it's a simple .cpp file). I think on the first commit it was detected as an utf-16 file (on windows). But no matter what I do I can't get it back to a "normal text" text file (git does not detect that), but I is now only utf-8. I also replace the whole content of the file with just 'a' and git say it's binary.

Is the only way to get it back to text-mode?:
* copy a utf-8 version of the original file
* delete the file
* make a commit
* add the old file as a new one

I think that will work but it will also break my history.

Is there a better way to get these behavior without losing history?

+1 vote

As far as I know, CORE file contains all the information till Segmentation fault. Then, while debugging core file why we are using executable file(binary) with it.?

+3 votes

I need to change the Wifi channel programmatically (Of course, I will enable the Wifi to function as Hotsopt first).
Is there any API/Driver in the source code that I can use?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.