how to solve this problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dasarath mood
    New Member
    • Nov 2006
    • 11

    how to solve this problem

    In c i have to create new directory , i have to add the files to the directory and
    we have to add this new directory to another old directory..plea se suggest any solution to this problem...
  • svsandeep
    New Member
    • Nov 2006
    • 15

    #2
    Hmm,

    R u Expecting a solution with GUI for this. I dont get your question. Dont you think it can be easily done by using system() function in C. We can run all dos commands using it.

    Regards,
    ShaggY@FtF

    Comment

    • horace1
      Recognized Expert Top Contributor
      • Nov 2006
      • 1510

      #3
      Originally posted by dasarath mood
      In c i have to create new directory , i have to add the files to the directory and
      we have to add this new directory to another old directory..plea se suggest any solution to this problem...
      if you are using the GNU C/C++ compiler (e.g. under Linux or with Cygwin or DEV-C++ under Windows) you can use the GNU mkdir() function, see
      http://www.delorie.com/gnu/docs/glibc/libc_282.html

      a simple bit of code would be
      Code:
           int result;
           if((result=mkdir("testdir", 0x700))==0) printf("mkdir OK");
           else                                    perror("mkdir fail");

      Comment

      • dasarath mood
        New Member
        • Nov 2006
        • 11

        #4
        Originally posted by svsandeep
        Hmm,

        R u Expecting a solution with GUI for this. I dont get your question. Dont you think it can be easily done by using system() function in C. We can run all dos commands using it.

        Regards,
        ShaggY@FtF
        hi man, i want to write code in c man..not GUI or running DOS commands..

        Comment

        • svsandeep
          New Member
          • Nov 2006
          • 15

          #5
          Originally posted by dasarath mood
          hi man, i want to write code in c man..not GUI or running DOS commands..

          Hmm,

          if you look at my post. I said "using system function in C "


          Please find below what a system command can do..

          Read the command you want to run in to a string variable and then pass the variable to system function....

          #include <stdlib.h>
          int system( const char *command );

          The system() function runs the given command as a system call. The return value is usually zero if the command executed without errors. If command is NULL, system() will test to see if there is a command interpreter available. Non-zero will be returned if there is a command interpreter available, zero if not.



          eg: system("MKDIR shaggy");

          will create a directory with name shaggy. similarly you can use any command which can run on dos. use this in your code it will make things simple.. :)

          Regards,
          ShaggY@FtF.

          Comment

          • DeMan
            Top Contributor
            • Nov 2006
            • 1799

            #6
            perhaps I'm wrong, but I think you miss the point in the replies to your post...both of them have given solutions IN c which will work. svsandeep suggests
            Dont you think it can be easily done by using system() function in C
            . What he means is you use system() to call a command line function, that is you can create directories THROUGH C by calling the command line.
            mkdir() as horace1 suggests will make a directory (irrespective of GUI or not) and either way is still called through c.

            Maybe I missed the point, could you rephrase the question?

            Comment

            • dasarath mood
              New Member
              • Nov 2006
              • 11

              #7
              Originally posted by DeMan
              perhaps I'm wrong, but I think you miss the point in the replies to your post...both of them have given solutions IN c which will work. svsandeep suggests . What he means is you use system() to call a command line function, that is you can create directories THROUGH C by calling the command line.
              mkdir() as horace1 suggests will make a directory (irrespective of GUI or not) and either way is still called through c.

              Maybe I missed the point, could you rephrase the question?
              ok thanks for all of u..i got some points from u

              Comment

              Working...