I got some maybe stupid questions about file output and functions.
At first I have to say I'm programming on Linux.
The first thing is I couldn't find a function which can tell me
microseconds and the second is that I couldn't find a characterreadin g
unbuffered function.
Also I couldn't compare the cursorpositions in files.
And the last thing is that I couldn't insert text in a file(or delete
it) with the function fopen() and then using fprintf(). Either I
overwrote the hole file or I just attached the text to the end.
I hope you can help me.
Thanks in advance. 4 2056
Erik Paul wrote: I got some maybe stupid questions about file output and functions. At first I have to say I'm programming on Linux.
When it is necessary to mention the system you are using,
it is usually the case that the questions are about that system
and not about the C programming language. You will probably
get better answers from a newsgroup devoted to Linux, or to
Unix programming in general.
The first thing is I couldn't find a function which can tell me microseconds [...]
Standard C provides time() to measure "real-world" time and
clock() to measure processor time. Standard C does not specify
the accuracy of these measurements, nor the precision of their
expression. For some non-Standard possibilities that might be
available on your system, see Question 19.37 of the comp.lang.c
Frequently Asked Questions (FAQ) list at http://www.eskimo.com/~scs/C-faq/top.html
and the second is that I couldn't find a characterreadin g unbuffered function.
This is Question 19.1.
Also I couldn't compare the cursorpositions in files.
I am not sure what you mean by "cursorposition ." If you
mean the position at which the next read would start, ftell()
can provide this as a number -- but the number might not be
meaningful for a text stream.
And the last thing is that I couldn't insert text in a file(or delete it) with the function fopen() and then using fprintf(). Either I overwrote the hole file or I just attached the text to the end.
This seems to be Question 19.14, or possibly 19.13.
-- Er*********@sun .com
Erik Paul <In************ **@freenet.de> writes: I got some maybe stupid questions about file output and functions. At first I have to say I'm programming on Linux.
That's a bad sign--if you have to say what platform you're using,
then the question is probably off-topic in comp.lang.c, because
we only discuss the standard C programming language here.
Extensions and system-specific features are off-topic.
The first thing is I couldn't find a function which can tell me microseconds
If you mean "the current time in microseconds", there's nothing
in standard C that can portably tell you that. Try
comp.unix.progr ammer for system-specific information.
and the second is that I couldn't find a characterreadin g unbuffered function.
You can use setvbuf() to turn off buffering for a file, then
getc() to read a character from it unbuffered. However, if you
mean "read a character from the user without waiting", see C FAQ
19.1. (Use Google to find the FAQ.)
Also I couldn't compare the cursorpositions in files.
In binary files, you can call ftell() to find out the current
number of characters from the beginning of the file. If ftell()
fails, as it might if you're at a position in the file that can't
be represented as a long int, it returns -1.
And the last thing is that I couldn't insert text in a file(or delete it) with the function fopen() and then using fprintf(). Either I overwrote the hole file or I just attached the text to the end.
See C FAQ 19.14.
--
"Some programming practices beg for errors;
this one is like calling an 800 number
and having errors delivered to your door."
--Steve McConnell
On Mon, 15 Dec 2003 18:22:37 +0100, Erik Paul
<In************ **@freenet.de> wrote: The first thing is I couldn't find a function which can tell me microseconds
When I want to time small functions or sections of code, I use an
assembler function that gets the Pentium or AMD processor's "time
stamp counter" into EDX;:EAX. The function, therefore, returns a
"long long" value. It's just "rdtst" followed by "ret". The function
itself requires 53-115 clocks to run, including the cost of assigning
the returned value to a variable. A microsecond counter isn't much
use except for pieces of code that take at least several microseconds
to run. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Moe |
last post by:
I have a winForm control that contains an openFileDialog.
I am using this control in a webForm by enbedding it using an <object> tag.
I need to access some information about the file on the client.
I strongly named my control assembly .
I created a machine level permission set, and assigned FileDialog, FileIO
and User interface permission.
I created a code group under all_Code, associated my assembly's strong name
to that group and...
|
by: Steven Smith |
last post by:
Hi guy's I've hit a bit of a sticking point, I'm sure
this is simple enough but I just can't get my head around
it and I'm looking for a bit of direction. When dealing
with FileIO up until now I would have created a user-
defined data structure to store my data from which I
could load / save to a Random Access Text File via
textboxes etc on the form. However the problem I'm now
facing is twofold.
firstly:
|
by: Sakharam Phapale |
last post by:
Hi All,
I am using an API function, which takes file path as an input.
When file path contains special characters (@,#,$,%,&,^, etc), API function
gives an error as "Unable to open input file".
Same file path containing special characters works fine in one machine, but
doesn't work in other.
I am using following API function to get short file path.
Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As
|
by: Cruella DeVille |
last post by:
I'm writing a class to handle reading/writing from/to files like this
(shortened)
lass FileIO{
private $filename;
private $mode;
private $filePointer;
private $dictionary;
public function __construct($filename = null, $mode = 'r+'){
|
by: Marquis |
last post by:
I am writing a ActiveX dll using Visual C#
However , i am facing fileio and environment permission problem.
Is there any way to solve this problem? just as signing the dll or
other method to grant the permission?
Thanks,
Marquis
| |
by: dgk |
last post by:
I can't find anything in the framework that will tell me whether a
filename is valid. I suppose that I can just try to open it and trap
an error but that seems wasteful. I dug around and found this code:
Public Function IsValidName(ByVal name As String) As Boolean
Dim i As Integer
For i = 0 To name.Length - 1
Dim ch As Char = name.Chars(i)
Dim uc As Globalization.UnicodeCategory =
|
by: =?Utf-8?B?bWFnZWxsYW4=?= |
last post by:
Hi All,
I have the following:
FileIO.FileSystem.CopyDirectory(strFromString, strLocString,
FileIO.UIOption.AllDialogs)
Q: How do I access the UI that is presented and re-positon the x,y location..?
|
by: =?Utf-8?B?bWFnZWxsYW4=?= |
last post by:
hi all,
I have a button (stopcopy) that I want the user to cancel out of a long file
copying operation.
I'm not clear what I should "adding" in the sub to make this happen besides
& return. I want to stop/cancel the file io operation and return back to the
calling form.
|
by: Gary Herron |
last post by:
Marlin Rowley wrote:
You don't need the newsgroup to answer this kind of question. Just try it!
abcdefghi abcd
Notice that the index does not change the original array.
Gary Herron
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |