User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 426,493 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,309 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 380 | Replies: 6 | Solved
Join Date: May 2008
Location: Mumbai, India
Posts: 4
Reputation: harsh2327 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
harsh2327 harsh2327 is offline Offline
Newbie Poster

How to read complete file names???

  #1  
May 10th, 2008
I want to read files and folder names from directories.
I have used the following code.
But the problem is that in the output the file name gets truncated.(See the output below)



  1. #include <dirent.h>
  2. #include <stdio.h>
  3. #include<conio.h>
  4.  
  5. void main(void)
  6. {
  7. clrscr();
  8. DIR *d;
  9. struct dirent *dir;
  10. d = opendir(".");
  11. if (d)
  12. {
  13. while ((dir = readdir(d)) != NULL)
  14. {
  15. printf("%s\n", dir->d_name);
  16. }
  17.  
  18. closedir(d);
  19. }
  20.  
  21. getch();
  22. }



=====
OUTPUT
=====
ABCABC~1.CPP
CURREN~1.EXE
CURREN~1.OBJ
============

The actual naes of the files are:
abcabcd.cpp
currentfolder.exe
currentfolder.obj


I would like to read the files as their original names....but I am unable to do so..

Please help!!
Last edited by harsh2327 : May 10th, 2008 at 4:11 am.
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:03 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC