|
<blockquote class="quote"><div class="op">Quote:</div>
#include <sys/types.h>
#include <sys/dir.h>
#include <sys/param.h>
#include <stdio.h>
#include "Utility.c"
#include "Utility.h"
#include <math.h>
#define FALSE 0
#define TRUE !FALSE
extern int alphasort();
char pathname[MAXPATHLEN];
main() { int count,i;
struct direct **files;
int file_select();
if (getwd(pathname) == NULL )
{ printf("Error getting path\n");
exit(0);
}
printf("Current Working Directory = %s\n",pathname);
count =
scandir(pathname, &files, file_select, alphasort);
if (count <= 0)
{ printf("No files in this directory\n");
exit(0);
}
printf("Number of files = %d\n",count);
for (i=1;i<count+1;++i){
printf("\n%s\n ",files[i-1]->d_name);
int SizeOfData,j;
float *data;
char *wavFileName=".wav";
FILE *fout;
data=wavRead(files[i-1]->d_name,&SizeOfData) ;
printf("\nReading Done\n");
fout = fopen ("dataSamples","w");
j=0;
while (j < SizeOfData) {
fprintf(fout, "%f\n",data[j]);
j++;
}
}
printf("\n");
}
int file_select(struct direct *entry)
{ char *ptr;
char *rindex(char *s, char c);
if ((strcmp(entry->d_name, ".") == 0) ||
(strcmp(entry->d_name, "..") == 0))
return (FALSE);
ptr = rindex(entry->d_name, '.');
if ((ptr != NULL) &&
((strcmp(ptr, ".wav") == 0) ))
return (TRUE);
else
return (FALSE);
}
</blockquote>
// along with the output if what shall i do for getting text file of the output also.?
|
|
|
|
|
You should not use fprintf to write binary data (.wav files); use WriteFile as I suggested in my previous post. You can use fprintf to create a text file containing the names of all your files.
|
|
|
|
|
do this WriteFile function work in ubuntu ?
|
|
|
|
|
My apologies, you need fwrite[^] in Linux.
|
|
|
|
|
Your program could simply write its output to console (e.g. using printf function, or cout object), then (on program invocation) you may redirect the standard output to a text file, e.g.
myprogram > myfile.txt
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
Actually without giving command I want to generate itself..that why but Thanks anyhow..
|
|
|
|
|
By the way how to use this function?
|
|
|
|
|
|
#include <sys/types.h>
#include <sys/dir.h>
#include <sys/param.h>
#include <stdio.h>
#define FALSE 0
#define TRUE !FALSE
extern int alphasort();
char pathname[MAXPATHLEN];
main() { int count,i;
struct direct **files;
int file_select();
if (getwd(pathname) == NULL )
{ printf("Error getting path\n");
exit(0);
}
printf("Current Working Directory = %s\n",pathname);
count =
scandir(pathname, &files, file_select, alphasort);
if (count <= 0)
{ printf("No files in this directory\n");
exit(0);
}
printf("Number of files = %d\n",count);
for (i=1;i<count+1;++i)
printf("\n%s\n ",files[i-1]->d_name);
printf("\n");
}
int file_select(struct direct *entry)
{ char *ptr;
char *rindex(char *s, char c);
if ((strcmp(entry->d_name, ".") == 0) ||
(strcmp(entry->d_name, "..") == 0))
return (FALSE);
ptr = rindex(entry->d_name, '.');
if ((ptr != NULL) &&
((strcmp(ptr, ".c") == 0) ||
(strcmp(ptr, ".txt") == 0) ||
(strcmp(ptr, ".m") == 0) ))
return (TRUE);
else
return (FALSE);
}
debina
|
|
|
|
|
the output is displaying file and folder from desktop but i want to display the file inside the folder with specific extension...
|
|
|
|
|
|
I am not able to get you path means? but this program is displaying the file present in desktop..
|
|
|
|
|
What is the full directory path that gets stored in pathname by the getwd function?
|
|
|
|
|
|
Well that seems clear. How exactly do you think that using that path for your scandir will return files from a different folder?
|
|
|
|
|
Actually that was my problem of not working with different location ...that y I uploaded to find solution over here..
|
|
|
|
|
I don't see a problem; you get the path of the desktop and list the files in it. If you want to list the files of a different folder then get the correct path for the folder in question. And don't use getwd (or getcwd ) unless you are certain that you are rooted in the correct directory to start with. Use a different method to select the folder you wish to list.
|
|
|
|
|
thank you ...counted I will kip in mind...
|
|
|
|
|
With visual studio 6 you were able to delete the .clw file to re-build the class wizard if you made a lot of changes in the source files and that were not showing in the class wizard.
How do you do this with VS 2010 - there is no longer a .clw file.
|
|
|
|
|
|
I want to update the database based on triggers . I need the database to get updated automatically based on already written code.I do not want to manually execute queries to update the database
|
|
|
|
|
So what is your question?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
If you have a CMFCShellListCtrl..........CListCtrl with multiple selections?
|
|
|
|
|
Hey guys,
I'm encountering the following problem. I wolud very much appreciate your help.
Description of the problem
MFC Desktop Application
VisualStudio 2010
Icons are supposed to be displayed in a CListCtrl as a CImageList.
It usually works fine except when using RemoteDesktop with the OS Windows 2008 / 2003.
In these particular cases the icons are just displayed as a black square.
Connecting with VMware vSphere (alternative to RemoteDesktop) -> Icons are shown appropriately
Remotdesktop on Windows XP / 7 / 8 -> Icons are shown appropriately
Code:
OnInitDialog()
{
/*
~Standardcode
*/
// Setting the symbol for this dialog-field. This is done automatically
// if the mainwindow of the application is no dialog-field.
SetIcon(m_hIcon, TRUE); // using big symbol
SetIcon(m_hIcon, FALSE); // using small symbol
// TODO: appending additional initialization
InitList(); //
m_list.SetImageList(imageList, LVSIL_NORMAL);
//captions
CString buf = _T("testitem");
m_list.InsertItem(0, buf, 0);
m_list.SetItemData(0, (DWORD) 0);
m_list.SetItemText(0, 0, _T("0"));
m_list.SetItemState(0, 2, LVIS_SELECTED);
m_list.EnsureVisible(0, FALSE);
}
void CDispomarkierungTestDlg::InitList()
{
imageList = new CImageList();
int err = imageList->Create(16, 16, ILC_COLOR32 | ILC_MASK, 1, 1); //ILC_COLOR16 , ILC_COLOR8 , ... getested
int id = 40;
int requiredLength = 3154;
LPCSTR picInCharsFromDB = GetBitmapAsText();
int width = 24;
int heigth = 24;
int pixel = 32;
int planes = 1;
BYTE *picInBytes = new BYTE[requiredLength];
int lengthVariable = requiredLength;
int* lengthPointer;
lengthPointer = &lengthVariable;
Base64Decode(picInCharsFromDB, requiredLength, picInBytes, lengthPointer);
HANDLE hBitMap = CreateBitmap(width, heigth, planes, pixel, picInBytes);
BITMAP bitmap;
GetObject(hBitMap,sizeof(BITMAP),&bitmap);
CImage image;
image.Attach((HBITMAP)hBitMap);
CBitmap icon;
icon.Attach((HBITMAP)hBitMap);
CBitmap* bitmappointer;
bitmappointer = &icon;
BITMAP bmp;
icon.GetBitmap(&bmp);
CClientDC dcClient(this);
CDC memDC;
memDC.CreateCompatibleDC(&dcClient);
HBITMAP hbmMask = ::CreateCompatibleBitmap(memDC.GetSafeHdc(), width, heigth);
ICONINFO ii = {0};
ii.fIcon = TRUE;
ii.hbmColor = icon;
ii.hbmMask = hbmMask;
HICON hIcon = ::CreateIconIndirect(&ii);
::DeleteObject(hbmMask);
err = imageList->Add(hIcon);
}
In the real application, the source is a database which saves the Bitmap as a string. That’s the reason for the complicated code during the loading. Loading the images as a resource is possible, but in this case no option.
Drivers of server and client are updated to latest version.
I added the project here https://www.hidrive.strato.com/lnk/gRuMg38R. Thanks for helping out
|
|
|
|