Re: function




"Joachim Schmitz" <nospam.jojo@xxxxxxxxxxxxxxxxxx> wrote in message
news:g1rpes$mp7$1@xxxxxxxxxxxx
[OT]
dd if=/dev/zero of=<your file> count=<your size>
[/OT]

Ah. The easy way out :)

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

int
main (int argc, char *argv[])
{
if (argc != 3)
{
puts ("usage error");
exit (EXIT_FAILURE);
}
char a = '0';
char a = '\0';

Why the termination string character? Do you mean to replace my line or
are you adding one?

int b, num;
FILE *fp;
num = atoi (argv[2]);
fp = fopen (argv[1], "wb");

I am thinking that I would need a for loop involved here
somewhere. I am not sure what to put in the body.

while (num--)
fputc(a, fp);
fclose(fp);
return 0;
}

Still needs some error checking (num>=0, fp != NULL, fclose and fput
worked)

I can get that part. I think.

Bill
Bye, Jojo



.



Relevant Pages

  • Re: Maintaining multivariable state (newbie question)
    ... extended with various options, and I've ended up making each function taking (..., int argc, char *argv) and then each function would parse it. ... argc, char *argv), but for some reason I needed to change some of the things temporarily, and restore them, so I've ended up doing something like a stack for each global variable. ... And when I started reading lisp I understand the wisdom behind special variables, and all my wasted hours behind emulating what's already have been done. ... That plus the multiple-value returns (Another invention that I needed these days in a C++ code to overcome total rewrite of foreign code portions in a much larger tool - mainly to avoid massive amounts of DLL's to be recompiled). ...
    (comp.lang.lisp)
  • Re: The contents of the file is not read..
    ... int main(int argc, char *argv) ... Buffer overflow protection. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: Newbee needs once more again help with passing arrays out of a function
    ... int argc, char *argv) ... it's best to copy and paste a compilable program ... give them the starting address of some region in memory. ...
    (comp.lang.c)
  • [PATCH -tip 7/9] perf probe: Add argv_split() from lib/argv_split.c
    ... int argc, i, need_dwarf = 0; ... * Helper function for splitting a string into an argv-like array. ... char *strxfrchar; ...
    (Linux-Kernel)
  • Re: function
    ... main (int argc, char *argv) ... exit; ... Why the termination string character? ...
    (comp.lang.c)