Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-05-2016, 10:55 AM   #1
LQ Newbie
Registered: Feb 2016
Posts: 8

Rep: Reputation: Disabled
Copying the name of the next file in a directory to fname.

Hello! I am working on an assignment involving the creation of a simple file system. For one of the methods, I have to make is getnextfilename.What this basically does is that it copies the name of the next file in the directory into fname and returns non-zero if there is a new file.Once all of the files have been returned, it returns a zero.

This is what I have done, but I am not sure it is right.
int sfs_getnextfilename(char *fname){

	int i;
	int filenameindex = 1;

	for (i = 0; i < MAXFILE; i++ ){ 
		strncpy(fname, filename, 16);
		if(fname != filename){
			return 1;
	return 0;
I am very new to C, so please be considerate. Thank you for your help.
Old 04-05-2016, 01:11 PM   #2
Registered: Jul 2012
Distribution: Arch, Debian, and CentOS/RHEL
Posts: 540

Rep: Reputation: 56
What exactly is the problem? Where's your question? In the first place, what does the code have to do with Linux? It appears as a C program which practically runs on any platform.
Old 04-07-2016, 07:36 PM   #3
LQ Newbie
Registered: Feb 2016
Posts: 8

Original Poster
Rep: Reputation: Disabled
It is a supposed to be part of a mountable disk file system that run on Linux. I am not sure if this is supposed to be the right way to go about it.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
resuming file copying after remounting CIFS directory a1337q Linux - General 2 03-14-2011 01:33 PM
copying the .rhosts file to a remote directory kaplan71 Linux - General 1 01-24-2008 05:43 PM
Copying a single file into each directory of a directory tree mlapl1 Linux - Newbie 2 06-27-2007 10:18 PM
Copying a file into a directory Nizhni Linux - Newbie 3 01-24-2005 12:47 AM
Copying the newest file in a directory to another location Transition Linux - General 2 01-14-2005 11:53 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration