Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by Andrzej ( 15 years ago )
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 80

int main(int argc, char** argv)
{
 int count;
 
 printf("Nazwa programu: %s\n", argv[0]);
 
 if (argc > 1)
 {
  FILE *p = NULL;
   
   char *fileName = "./plik.txt";
   
   char* buffer;
   
   buffer = malloc(sizeof(char)*N);
   
   for(count = 1; count < argc; ++count)
   {
    sprintf(buffer, "argv[%d] = %s\n", count, argv[count]);
   }
   
   size_t lenght =0;
   
  p = fopen&#40;fileName,"w"&#41;;
   
   if(p==NULL)
   {
    perror("Blad");
   }
    
   lenght = strlen(buffer);
    
  
  fwrite(buffer,lenght,1,p);
  fclose(p);
   
   printf("zapisano\n");
 }
 else
 {
  printf("Program nie ma argumentow\n");
 }
 return 0;
}

 

Revise this Paste

Your Name: Code Language: