change subdirectory in for loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dschulenburg
    New Member
    • Oct 2006
    • 40

    #1

    change subdirectory in for loop

    Hi,

    I need to open files in different subdirectories of my local directory. The subdirectories have the names 1,2,3 ...,N. How can I make a for loop to open the files in the different folders ? Something like

    for( N ) {
    fpointer=fopen (../N/filename,"r")
    ...
    }

    ??
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    Originally posted by dschulenburg
    Hi,

    I need to open files in different subdirectories of my local directory. The subdirectories have the names 1,2,3 ...,N. How can I make a for loop to open the files in the different folders ? Something like

    for( N ) {
    fpointer=fopen (../N/filename,"r")
    ...
    }

    ??
    You may want to have a look at the sprintf function to assemble the file names.

    Comment

    • dschulenburg
      New Member
      • Oct 2006
      • 40

      #3
      Thanks ! That looks good !

      Originally posted by arne
      You may want to have a look at the sprintf function to assemble the file names.

      Comment

      Working...