Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem when executing my function, I have been putting it in the main but it does not execute (it does not mark any error either) and I have been trying to execute it in the previous function (Column) but it does not allow me to execute it unless it is within the first for, otherwise it still cannot be executed, I have implemented an if condition, so that the call of the function is not repeated the n times that lasts the for cycle but I have realized that this condition generates that the matrix M

Translated with www.DeepL.com/Translator (free version)

What I have tried:

C++
void Renglon(){
    int etapa;
  int  z=0;

      for(i=0; i <= N-1; i++) {

         for(n=0; n< N; n++){
          x[n] = MC[i][n];
                
                  init_bro();
                  init_W();
                 ordena_ent();
         
                    for(etapa=1; etapa <= nbits; etapa++){
                    combina(etapa);
                    }
         
         }
                  z=z+1;
      printf("\n\n Salida = (%d) ", z); 
        for(m=0; m<N; m++)
           printf("\n x[%d] = %.2f + %.2f j", m, creal(mcombina[m][3]), cimag(mcombina[m][3]));
         //printf("\n x[%d,%d] = %.2f + %.2f j", m,i, creal(MC[m][7]), cimag(MC[m][7]));
  }
}
void Columna(){
    int etapa;
    int g = 0;
    int z=0;

        for(n=0; n <=64 ; n+=8, j=1+j)
        {
            for(i=0; i <= N-1; i++){
                 x[i] = (double)data[n+i][0] + data[n+i][1]*I;
         
                 init_bro();
                 init_W();
                 ordena_ent();
                   
            }   
        for(etapa=1; etapa <= nbits; etapa++){
            combina(etapa);
        }
          
                 for(i=0; i <= N-1; i++) {
	            MC[i][j] = mcombina[i][3];
                //MT[i][j]=MC[i][1];
             g=g+1;
                }
 
  if(g==8){ 
      Renglon();   
  }
}
 }
      

int main(int argc, char const *argv[])
{
	/* code */
	if (argc < 3){
		printf("Please specify the CSV file as an input.\n");
		exit(0);
	}

	char row     = atoi(argv[1]);
	char col     = atoi(argv[2]);
	char fname[256];	strcpy(fname, argv[3]);

	data = (double **)malloc(row * sizeof(double *));
	for (int i = 0; i < row; ++i){
		data[i] = (double *)malloc(col * sizeof(double));
	}
 int etapa;
	read_csv(row, col, fname, data);
    Columna();
    Renglon();
return 0;
    }
Posted
Updated 27-Jun-21 7:42am
v2
Comments
k5054 27-Jun-21 13:37pm    
Is some of your code missing? You say "it does not mark any error either", which I take to mean your code compiles cleanly, but the given code does not. In particular there is no declaration of variables i, x, N in scope for functions Columna and Renglon.
Wilfrido López 27-Jun-21 14:49pm    
The code is indeed not completely published, but it does not show any error, the output is not the desired one.
I would be very grateful if you could provide me with your facebook or email address to specify my errors and send you the complete code, I would appreciate it very much.
KarstenK 27-Jun-21 13:43pm    
maybe you havent provided the args. Use the debugger.

1 solution

We can't really help you on this code as it is not complete and depend on external data file.
Quote:
I have a problem when executing my function, I have been putting it in the main but it does not execute

Your code do not behave the way you expect, or you don't understand why !

There is an almost universal solution: Run your code on debugger step by step, inspect variables.
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't know what your code is supposed to do, it don't find bugs, it just help you to by showing you what is going on. When the code don't do what is expected, you are close to a bug.
To see what your code is doing: Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

1.11 — Debugging your program (stepping and breakpoints) | Learn C++[^]

The debugger is here to only show you what your code is doing and your task is to compare with what it should do.
 
Share this answer
 
Comments
Wilfrido López 27-Jun-21 14:50pm    
The code is indeed not completely published, but it does not show any error, the output is not the desired one.
I would be very grateful if you could provide me with your facebook or email address to specify my errors and send you the complete code, I would appreciate it very much.

Please :)
Patrice T 27-Jun-21 15:07pm    
"The code does not show any error, the output is not the desired one."
This is when debugging starts.
CPallini 28-Jun-21 6:08am    
5.
Patrice T 28-Jun-21 6:27am    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900