title: don't want to create a write protected
body: <p>I have this assignment, part of it needs to create some files that have the name xNNNNNN, where NNNNNN is replaced by a random six-digit number and the files should be created in the random order in which their names are generated, I've already do that but the problem is that the files I get is a <strong>write protected</strong> but I want them to be <strong>write only</strong>, what I'm doing wrong ?? is it related to the flags or something else ?</p>
  
  <p>here is what I write : </p>
  
  <pre><code>  int file;
    int fileName;
    int counter;
    char str1[5];
    char str2[5];
    int fileNum = atoi(argv[2]);
  
    for (counter = 0; counter &lt; fileNum ; counter++)
    {
       fileName = rand() % 900000 + 100000; 
  
       sprintf (str1, "%d", fileName); //write the value of r as a string in str
       sprintf (str2, "%s%s", "x", str1);
       printf ("%s\n" ,str2); 
  
       file = open (str2, O_WRONLY|O_CREAT, S_IRUSR | S_IRGRP | S_IROTH); 
       if (file != -1)
       {
           //do something 
       } 
    }
  </code></pre>