The problem I'm having is that my serial-inverter pointer gets all null, and the rest of the code works fine, I really do not see what the problem is! If somebody can help me, I thank you right away! Note: You have a few more libraries to use in other codes that have no connection with this one!
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);
}