1
The problem I’m having is that my serial pointer is all null, and the rest of the code runs good, I really can’t find what the problem is! If anyone can help me I appreciate it already!! Obs.: There are some more blibiotecas for use in other codes that n has no connection with the one in question!
main:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include "repository.h"
int main()
{
int *serieoriginal;
int *serieinversa;
unsigned int i, j;
serieoriginal = (int*) calloc(12, sizeof(int));
serieinversa = (int*) calloc(12, sizeof(int));
printf("Bem vindo ao modo de musica Dodecafonico!\n\n");
printf("Digite os valores da serie!\n");
Sleep(300);
for (i = 0; i < 12; i++) {
printf(" %d valor: ", i+1);
scanf("%d", &serieoriginal[i]);
}
*serieinversa = SeInv(serieoriginal);
printf("\nSerie original: ");
for (i = 0; i < 12; i++) {
printf("%d ", serieoriginal[i]);
}
printf("\nSerie inversa: ");
for (i = 0; i < 12; i++) {
printf("%d ", serieinversa[i]);
}
return 0;
}
blibioteca Repository. h:
#ifndef REPOSITORY_H_
#define REPOSITORY_H_
int* SeInv(int* s);
#endif
Repository. c:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int* SeInv(int *s)
{
int P[12]/*serie transposta*/, *R[12]/*serie retrogradada*/;
int i, k, aux;
srand( (unsigned)time(NULL) );
k = 5;//rand()%12;
printf("\n K: %d\n", k);
printf("\nSerie: ");
for (i = 0; i < 12; i++) {
printf("%d ", s[i]);
}
for (i = 0; i < 12; i++) {
aux = s[i];
aux = (aux + k)%12;
P[i] = aux;
}
printf("\nP: ");
for (i = 0; i < 12; i++) {
printf("%d ", P[i]);
}
k = 0;
for (i = 12; i > 0; i--) {
R[k] = P[i-1];
k++;
}
printf("\nR: ");
for (i = 0; i < 12; i++) {
printf("%d ", R[i]);
}
return (*R);
}
Why the c++ and c tags#?
– Pablo Almeida
Young, C, C++ and C# are not the same thing.
– Jéf Bueno
I put it only to have a wider range of people who could help me!
– Guilherme Gehlen