Click here to Skip to main content
15,890,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: calling of function ? Pin
CPallini4-Aug-14 21:23
mveCPallini4-Aug-14 21:23 
GeneralRe: calling of function ? Pin
Stefan_Lang5-Aug-14 22:37
Stefan_Lang5-Aug-14 22:37 
AnswerRe: calling of function ? Pin
Satya Chamakuri13-Aug-14 20:34
Satya Chamakuri13-Aug-14 20:34 
GeneralRe: calling of function ? Pin
mybm119-Aug-14 18:13
mybm119-Aug-14 18:13 
QuestionWhich IDE is good for programming in C Pin
SHUVO BISWAS2-Aug-14 21:40
SHUVO BISWAS2-Aug-14 21:40 
AnswerRe: Which IDE is good for programming in C Pin
CPallini3-Aug-14 0:14
mveCPallini3-Aug-14 0:14 
AnswerRe: Which IDE is good for programming in C Pin
«_Superman_»3-Aug-14 3:31
professional«_Superman_»3-Aug-14 3:31 
Questionhow do i make another main.c file where i can call this program and run according to it..? Pin
mybm11-Aug-14 20:31
mybm11-Aug-14 20:31 
<blockquote class="quote"><div class="op">Quote:</div>//===HEADER FILE ==============================================
#include"Utility.h" // IMPORT HEADER FILE 
#include"Utility.c" // IMPORT C FILE 
#include <sys/types.h>  // for scandir
#include <sys/dir.h>    // for alphasort and structure dirent 
#include <sys/param.h> 

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define FALSE 0
#define TRUE !FALSE



float square(float b);		// FUNCTION FOR SQUARING NUMBER ...
//float summation(float g);
char pathname[MAXPATHLEN];      

int main(int argc,int *argv[])
{
	int count,i;
	struct direct **files;     	//pointer to a pointer ,which point to the object call files here
	int file_select();
                                	//printf("\n enter the file ")
	if (getwd(pathname) == NULL )   // return absolute file name of current directory
						
		{ 
			printf("Error getting path\n");
			exit(0);
		}
				

					//printf("Current Working Directory = %s\n",pathname);
				        //printf("\n \nFile with extension .wav are as follows\n ");

	count =	 scandir(pathname, &files, file_select, alphasort);	//scandir returns the current directory (.) and the 										directory above this (..) as well as all files so we need to check
 
				
//================= If no files found, make a non-selectable menu item  ========================================
	if (count <= 0)
	       {		
		        printf("No files in this directory\n");
			exit(0);
	       }

			printf("\n Number of files = %d\n",count);
			for (i=1;i<count+1;++i)
			{
						// displaying the list of the file 
						 printf("\n%s\n  ",files[i-1]->d_name);


						srand(12345); // generate same random number anytime it run
							       //srand((unsigned int)time NULL)
						int i,j;
						float y,sum=0.0;
						float a=0.2;
						float summation=0.0;
						int SizeOfData;
						float *data;

	
	data=wavRead(files[i-1]->d_name,&SizeOfData) ;  

//================== OUTPUT DISPLAY SCREEN======================================================================

        printf("\n\n========================================================\n");
	printf("Generated random number\t ||   Squaring of random number:\n"); 
	printf("=========================================================\n");
     
	for(i=0;i<SizeOfData;i++)
		{
             		float f= ((float)rand()/(float)(RAND_MAX))*a; //rand return integer value from 0 to RAND_MAX(system dependent)
         		//float y[5];
		
			printf("%f\t",f);
//			printf("%f\t",((float)rand()/(float)(RAND_MAX))*a);
    			
			y=square(f);
			printf("\t\t%f\n",y);
   
                        sum +=y;
 //     	        printf("\t\t%f\n",f*f);
//      	        printf("\t\t%f\n",(((float)rand()/(float)(RAND_MAX))*a) * ((float)rand()/(float)(RAND_MAX) *a));
		
               }
          


                       
 	    /*    for(i=0;i<100;i++)
             		 {  //float y,sum;
					float f= ((float)rand()/(float)(RAND_MAX))*a;
					y=square(f);
					//printf("\t\t%f\n",y);
        				sum +=y;
	     		 }	 */	
		printf("\n===================================================\n");
		printf("\n TOTAL SUM OF THE SQUARED NUMBER := %f\t\n",sum);   
                summation=sum/SizeOfData;
                printf("\n ENERGY OF NOISE SIGNAL := \t%f/%d=%f\n\n",sum,SizeOfData,summation);
		  
  

//===== Printing of the value in the file mode by generating R_NUMBER file at the directory=======================================
       
			FILE *fout;
		//	int SizeOfData;
			fout=fopen("NOISE SIGNAL","w");  // output file in write mode
			j=0;
			sum=0.0;
			srand(12345);                // to giving value 12345 generate same random number wen anytime it run
			//int L1=63530;
			
			

			fprintf(fout,"\n================================================================\n");
			fprintf(fout,"\nGENERATED RANDOM NUMBER  ||  SQUARING OF GENERATED RANDOM NUMBER\n");
			fprintf(fout,"\n=================================================================\n");

			

			while(j<SizeOfData)                 // condition
			{ 
				 float f= ((float)rand()/(float)(RAND_MAX))*a;
				 y=square(f);
				
  				 fprintf(fout,"\t%f\t\t\t%f\n",f,y); // print file in output mode
				 sum +=y;
  		   	         j++;
			}
			fprintf(fout,"\n===============================================\n");
			fprintf(fout,"\nTOTAL SUM OF THE SQUARED NUMBER:=\t%f",sum);
			summation=sum/SizeOfData;
			fprintf(fout,"\nENERGY OF NOISE SIGNAL e(n):=\t%f/%d  =   %f\n\n",sum,SizeOfData,summation);
		
			fclose(fout);  // close the file

//return 0;
}

//========================= function of squaring of the random number===========================================
float square(float b)
{
	float z;
	z=b*b;
//printf("\t\t%f\t\t%f\t\t",z,b);
	return(z);
}
//===============================================================================================================

</blockquote>

AnswerRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan1-Aug-14 21:01
mveRichard MacCutchan1-Aug-14 21:01 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
mybm11-Aug-14 21:09
mybm11-Aug-14 21:09 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan1-Aug-14 21:45
mveRichard MacCutchan1-Aug-14 21:45 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
mybm11-Aug-14 23:34
mybm11-Aug-14 23:34 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan2-Aug-14 0:41
mveRichard MacCutchan2-Aug-14 0:41 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
mybm12-Aug-14 2:06
mybm12-Aug-14 2:06 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan2-Aug-14 2:49
mveRichard MacCutchan2-Aug-14 2:49 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
CPallini2-Aug-14 2:59
mveCPallini2-Aug-14 2:59 
GeneralRe: how do i make another main.c file where i can call this program and run according to it..? Pin
Richard MacCutchan2-Aug-14 3:05
mveRichard MacCutchan2-Aug-14 3:05 
AnswerRe: Put the other main in a namespace Pin
Software_Developer2-Aug-14 7:10
Software_Developer2-Aug-14 7:10 
GeneralRe: Put the other main in a namespace Pin
CPallini3-Aug-14 0:20
mveCPallini3-Aug-14 0:20 
QuestionC++ ofstream System.AccessViolation Pin
Kit Fisto1-Aug-14 5:07
Kit Fisto1-Aug-14 5:07 
QuestionRe: C++ ofstream System.AccessViolation Pin
CPallini1-Aug-14 6:11
mveCPallini1-Aug-14 6:11 
AnswerRe: C++ ofstream System.AccessViolation Pin
Kit Fisto1-Aug-14 6:22
Kit Fisto1-Aug-14 6:22 
GeneralRe: C++ ofstream System.AccessViolation Pin
CPallini1-Aug-14 22:05
mveCPallini1-Aug-14 22:05 
AnswerRe: C++ ofstream System.AccessViolation Pin
Kit Fisto4-Aug-14 23:49
Kit Fisto4-Aug-14 23:49 
AnswerRe: C++ ofstream System.AccessViolation Pin
Member 138550171-Jun-18 13:43
Member 138550171-Jun-18 13:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.