Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > creating a file

Reply
Thread Tools

creating a file

 
 
Rui Maciel
Guest
Posts: n/a
 
      02-25-2011
jacob navia wrote:

> Le 25/02/11 15:10, Rui Maciel a écrit :
>> jacob navia wrote:
>>
>>> I develop under windows and iphone/Apple. Lately, I got bored with
>>> windows and changed to Apple, a great platform. It makes Unix
>>> shine, it is a very good combination of a good GUI with a powerful
>>> Unix system. Linux folks could learn something from them, after
>>> more than a decade their system is as "usable" as SCO + Xwindows
>>> was.

>>
>> When was the last time you gave any linux distro a try?
>>
>>
>> Rui Maciel

>
> I am using Ubuntu, last time I used it was around 5 minutes ago.
> And when was the last time you used Mac OSX?
>
>


I posted that question because you made the following claim:

<quote>
after more than a decade their system is as "usable" as SCO + Xwindows
was.
</quote>

There are a hand full of desktop environments for linux which evolved
considerably and brought linux into the forefront of usability. Some DEs
managed to do so well that their efforts have been the source of
inspiration for others (i.e., ripped off). A notorious example can be
found in how Microsoft found inspiration in KDE for it's windows 7 DE.
So, knowing this, it becomes clear that linux managed to considerably
improve it's usability, a long way since the days of SCO + Xwindows.


>
> What is missing in linux and what makes the strength of Mac OSX
> can be described in one word:
>
> INTEGRATION
>
> Cut and paste works very well, the applications have a similar look and
> feel, the GUI is nicely done, and the intuitive programs are easy on
> new people. My wife is using immediately her MacBook, without any
> training.


Was that the first time ever that your wife used a computer?


> Network configuration is done automatically, and it works. Integrated
> TV, music, DVD, camera, microphone, everything works.


The last time I've installed a linux distribution from scratch (Kubuntu
10.10) the only tweaking it needed was installing proprietary drivers for
my graphics card. In spite of that, the default driver worked flawlessly,
although the was no hardware acceleration. USB cameras work out of the
box too, provided they are UVC or, if it's not the case, there are drivers
for it. Therefore, I don't see a difference.

Besides that, playing music and DVDs leads the user to install extra
packages which aren't installed by default due to legal restrictions.
Even then, I would hardly call that unfriendly.


> As in Linux. Everything works under linux too because if it doesn't
> (what is most often the case) *I* can make it work. I have never
> found any problem under Linux that I could not fix. It just costed
> me HOURS of googling, etc. And I know for sure that only a professional
> would have been able to do that.
>
> Sometimes it just wasn't worth the effort.


I've been using linux almost exclusively for a considerable number of
years and, considering the state where linux in the desktop has been in
the last 3 years or so, I don't see that many problems.

Granted, I've managed to put together systems which were assembled from
components that are supported under linux and I tend to use polished
distributions from established projects. As a consequence, they work
flawlessly even after reinstalling the OS, without needing any tweaking
whatsoever, let alone costing any googling.

So, as it's possible to have a flawless linux system up and running right
from the moment the install process finishes (which takes about 8 minutes
or so) I don't see how linux isn't worth the effort, mainly because no
effort is actually needed.


> Linux is nice, I have several virtual machines with it running in my
> Mac. I test my code under linux gcc (that is different from Apple's
> gcc).
>
> It is a useful system for system administrators and big companies
> that need a cheap server system.
>
> Nothing else.


There is no problem if you believe that linux in the desktop is useless.
Those who actually use it may not agree with you but you are still
entitled to your opinion.


Rui Maciel
 
Reply With Quote
 
 
 
 
BartC
Guest
Posts: n/a
 
      02-25-2011
"Hans Vlems" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I was asked for a program that creates a file with a predermined
> filesize.
> Filesize is specifcied in bytes, but it is acceptable if the filesize
> ought to be a multiple of, say, the blocksize of the disk.
> On a VMS system creat has a few platform specific enhancements. But
> this needs to run on a WIndows XP system. Is there a function to do
> that, for either Visual C or the djgpp environment?


This seems to work under Windows, and uses only standard C functions. Some
error checking might be needed.

It skips N-1 bytes, then writes a single byte for a total of N bytes. N
should be 1 or more.

#include <stdio.h>
#include <stdlib.h>

#define FILESIZE 1000000

int main(void){
FILE *f;
char c=0;

f=fopen("testfile","wb");
fseek(f,FILESIZE-1,SEEK_SET);
fwrite(&c,1,1,f);
fclose(f);
}

--
Bartc

 
Reply With Quote
 
 
 
 
Rui Maciel
Guest
Posts: n/a
 
      02-25-2011
Chris H wrote:

> Last time I looked on the sight that tracks Linux distros about 50% were
> "obsolete / unsupported"


No one is forced to use a distribution which is either obsolete or
unsupported. Just pick a distro which actually works, and stuff tends to
actually work.


> This is the problem with Linux.... very many variations and half of them
> disappear after a year or so.


This point is mentioned frequently and no matter how many times it is
pointed out it always fails to become relevant. No one forces you to run
obscure and dead distros, as no one forces you to run each and every half-
baked distro that manages to pop out. Therefore, it's irrelevant if there
are "very many variations" or that if 90% of those may disapear after a
year. You only need to get your hands on a single distribution that
actually works, from a project that will not disapear in the near future.
Nowadays you have half a dozen distros that fit that description, and
pretty much you can use any of those without having to worry about
anything.


> Philipe Khan (Borland) said that UNIX
> would never become dominant because of the multiple versions (three or
> four I think at the time ) and he was a UNIX fan


It really depends on what you mean by "dominant". Over 90% of Top500's
entries are linux systems, and around 2/3 of the smartphone market is
attributed to linux. According to some yardsticks, these values may be
considered "dominant".


Rui Maciel
 
Reply With Quote
 
Dr Nick
Guest
Posts: n/a
 
      02-25-2011
Mark Bluemel <(E-Mail Removed)> writes:

> On Feb 24, 11:19*pm, Hans Vlems <(E-Mail Removed)> wrote:
>> ... Most people on c.l.c. either use Windows or at least are
>> familiar with it.

>
> Cue for a debate (or even a flame war). I haven't taken a census, but
> I'm far from convinced that the majority here have experience of
> developing on Windows.


I've not got a Windows machine in the house, and haven't used it for
anything other than office work at work for over a decade now.
--
Online waterways route planner | http://canalplan.eu
Plan trips, see photos, check facilities | http://canalplan.org.uk
 
Reply With Quote
 
Dr Nick
Guest
Posts: n/a
 
      02-25-2011
Chris H <(E-Mail Removed)> writes:

> In message <4d67b86a$0$14166$(E-Mail Removed)>, Rui Maciel
> <(E-Mail Removed)> writes
>>jacob navia wrote:
>>
>>> I develop under windows and iphone/Apple. Lately, I got bored with
>>> windows and changed to Apple, a great platform. It makes Unix
>>> shine, it is a very good combination of a good GUI with a powerful
>>> Unix system. Linux folks could learn something from them, after
>>> more than a decade their system is as "usable" as SCO + Xwindows
>>> was.

>>
>>When was the last time you gave any linux distro a try?

>
> Last time I looked on the sight that tracks Linux distros about 50% were
> "obsolete / unsupported"
>
> This is the problem with Linux.... very many variations and half of them
> disappear after a year or so.


Whereas Windows hasn't changed at all in the last few years of course!
How long did Vista last for?
--
Online waterways route planner | http://canalplan.eu
Plan trips, see photos, check facilities | http://canalplan.org.uk
 
Reply With Quote
 
Michael Press
Guest
Posts: n/a
 
      02-26-2011
In article
<(E-Mail Removed)>,
Hans Vlems <(E-Mail Removed)> wrote:

> On Feb 24, 7:59*pm, Keith Thompson <(E-Mail Removed)> wrote:
> > Hans Vlems <(E-Mail Removed)> writes:

>
> > Create the file, then write the specified number of bytes to it.
> >

> That was my first idea too, before the platform was revealed, Windows
> and NTFS.
> Windows routinely uses disks of 500 GB and more, so writing records is
> probably slow.
>
> > Or did you have something else in mind?

>
> So the idea of just writing enough (large) records to a file to match
> a prerequisite size might turn out as
> a very slow process. I don't know yet what filesizes will be desired.
> Anything < 1 GB and it wouldn't matter


fopen(3), fseek(3), fwrite(3), fclose(3). If the file is very, very large
use fsetpos(3) instead of fseek. The fwrite can be one byte.

$cat try.c
#include <stdio.h>

int main(void)
{
char a[1] = {0};
FILE *fp;

fp = fopen("eraseme", "w");
fseek(fp, 0x2000, SEEK_SET);
fwrite(a, sizeof(a[0]), 1, fp);
fclose(fp);
return 0;
}
$cc try.c
$ls -lo eraseme
ls: eraseme: No such file or directory
$./a.out
$ ls -lo eraseme
-rw-r--r-- 1 mdp 8193 Feb 25 22:02 eraseme


> much probably. Creating a file of 1 TB that way is something else
> again.
> What I had in mind was open a file, allocate the desired number of MB
> and close it. All the filesystem has to
> do is put an EOF marker in it. On VMS this works quite well, can be
> done from the commandline.
> There is no demand to make the file contiguous, at least not yet,
> because that is also fairly slow even on
> empty disks.
> So instead of disenganging my brain completely and go for the direct
> approach, I thought I'd better ask here
> first. Most people on c.l.c. either use Windows or at least are
> familiar with it.
> Portability is not an issue, as said I don't need this for my own
> systems.
> Hans


--
Michael Press
 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      02-26-2011
Michael Press <(E-Mail Removed)> writes:
<snip>
> fopen(3), fseek(3), fwrite(3), fclose(3). If the file is very, very large
> use fsetpos(3) instead of fseek. The fwrite can be one byte.


There is a problem with using fsetpos to set an specific byte offset: we
are told nothing about the fpos_t type other than that it is an object
type and that it can represent file positions. The fact that is it not
guaranteed to be either an integer type or even an arithmetic type is
presumably deliberate, so it can't be used in portable C to do anything
but return to previously determined positions.

<snip>
--
Ben.
 
Reply With Quote
 
Chris H
Guest
Posts: n/a
 
      02-26-2011
In message <4d681311$0$14171$(E-Mail Removed)>, Rui Maciel
<(E-Mail Removed)> writes
>Chris H wrote:
>
>> Last time I looked on the sight that tracks Linux distros about 50% were
>> "obsolete / unsupported"

>
>No one is forced to use a distribution which is either obsolete or
>unsupported. Just pick a distro which actually works, and stuff tends to
>actually work.


You completely missed the point. Some of the current list of obsolete
and unsupported distributions were the Ubuntu's of their day. My
point is almost ANY Linux distribution you pick stands at least a 50%
chance of becoming obsolete and unsupported within 5 years.

>This point is mentioned frequently and no matter how many times it is
>pointed out it always fails to become relevant.


Not true. It has become relevant for quite a few people but they tend
to not want speak about it publicly.

> No one forces you to run
>obscure and dead distros, as no one forces you to run each and every half-
>baked distro that manages to pop out.


Perhaps you can tell me EXACTLY which distributions will absolutely
certainly be here in 10 years time and which will not. Your house or
business will do as collateral for the bet.


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



 
Reply With Quote
 
Chris H
Guest
Posts: n/a
 
      02-26-2011
In message <(E-Mail Removed)>, Dr Nick
<(E-Mail Removed)> writes
>Chris H <(E-Mail Removed)> writes:
>
>> In message <4d67b86a$0$14166$(E-Mail Removed)>, Rui Maciel
>> <(E-Mail Removed)> writes
>>>jacob navia wrote:
>>>
>>>> I develop under windows and iphone/Apple. Lately, I got bored with
>>>> windows and changed to Apple, a great platform. It makes Unix
>>>> shine, it is a very good combination of a good GUI with a powerful
>>>> Unix system. Linux folks could learn something from them, after
>>>> more than a decade their system is as "usable" as SCO + Xwindows
>>>> was.
>>>
>>>When was the last time you gave any linux distro a try?

>>
>> Last time I looked on the sight that tracks Linux distros about 50% were
>> "obsolete / unsupported"
>>
>> This is the problem with Linux.... very many variations and half of them
>> disappear after a year or so.

>
>Whereas Windows hasn't changed at all in the last few years of course!
>How long did Vista last for?


Apples and oranges. How many versions of Linux are there? Never mid
different distributions. Windows, link Linux evolves.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



 
Reply With Quote
 
Anders Wegge Keller
Guest
Posts: n/a
 
      02-26-2011
Chris H <(E-Mail Removed)> writes:

> You completely missed the point. Some of the current list of
> obsolete and unsupported distributions were the Ubuntu's of their
> day. My point is almost ANY Linux distribution you pick stands at
> least a 50% chance of becoming obsolete and unsupported within 5
> years.


Microsoft have long ceased support for Windows 95, 98, NT 3.51,
4.0. It should not come as a big suprise that linux distros also will
be EOL at some point.


--
/Wegge

Leder efter redundant peering af dk.*,linux.debian.*
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a File object out of the contents of jar/zip file kotauk@gmail.com Java 5 04-06-2006 08:36 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net Web Controls 0 06-01-2005 02:36 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net 0 06-01-2005 02:36 PM
Any way to rename a current File without creating a new File object? C-man Java 9 04-11-2004 04:21 AM
What is better /standard for creating files. a cpp file with header or cpp and seperate file for header DrUg13 C++ 1 02-10-2004 09:20 AM



Advertisments