I need your help with this small part of my program. I have to create a database of products in C language and one of the functions that we have to use is called "initializar.c", its purpose is to initialize the field "product" with '\ 0' (the null character) for all the info info array entries (arrays of type struct). At first I did it this way:
/*Archivo del tipo .h (inv.h); contiene las librerías a utilizar en el
programa y la estructura con sus campos a usar.*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//Se crea la esctructura con los siguientes campos.
typedef struct{
char producto[30];
float coste;
unsigned existencia;
}inv;
inv info_inv[100];
-------------------------------------------
#include "inv.h"
//Prototipos:
FILE* mifopen(const char *, const char *);
void* mimalloc(unsigned);
unsigned menu1(void);
unsigned menu2(void);
void inicializar_lista(void);
int main(){
unsigned opc;
//inv info_inv[100], *t_inv;
/*Realizamos un bucle indefinido para que el programa continue cuantas
veces el usuario desee. Luego, llamamos el menu principal (menu1.c).*/
while(1){
opc = menu1();
if(opc == 1){
//t_inv = &info_inv[100]; inicializar_lista(t_inv);
incializar_lista(void);
}
else if(opc == 2){
printf("\nVerificar: %u.\n",opc);
}
else {
printf("\nERROR: Opcion NO mostrada en el Menu.\n");
printf("\nSalida del programa.\nBye!\n"); break;
}
}
system("PAUSE");
return 0;
}
--------------------------------------------------------
#include "inv.h"
//void inicializar_lista(inv *p){
void inicializar_lista(void){
unsigned i;
for(i = 0; i < 100; i++){
//p = &info_inv[i];
//p->producto[0]="/*Archivo del tipo .h (inv.h); contiene las librerías a utilizar en el
programa y la estructura con sus campos a usar.*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//Se crea la esctructura con los siguientes campos.
typedef struct{
char producto[30];
float coste;
unsigned existencia;
}inv;
inv info_inv[100];
-------------------------------------------
#include "inv.h"
//Prototipos:
FILE* mifopen(const char *, const char *);
void* mimalloc(unsigned);
unsigned menu1(void);
unsigned menu2(void);
void inicializar_lista(void);
int main(){
unsigned opc;
//inv info_inv[100], *t_inv;
/*Realizamos un bucle indefinido para que el programa continue cuantas
veces el usuario desee. Luego, llamamos el menu principal (menu1.c).*/
while(1){
opc = menu1();
if(opc == 1){
//t_inv = &info_inv[100]; inicializar_lista(t_inv);
incializar_lista(void);
}
else if(opc == 2){
printf("\nVerificar: %u.\n",opc);
}
else {
printf("\nERROR: Opcion NO mostrada en el Menu.\n");
printf("\nSalida del programa.\nBye!\n"); break;
}
}
system("PAUSE");
return 0;
}
--------------------------------------------------------
#include "inv.h"
//void inicializar_lista(inv *p){
void inicializar_lista(void){
unsigned i;
for(i = 0; i < 100; i++){
//p = &info_inv[i];
//p->producto[0]="%pre%";
info_inv[i].producto[0] = '%pre%';
}
}
";
info_inv[i].producto[0] = '%pre%';
}
}
When I compiled the program I got this error: [Warning] assignment makes integer from pointer without a cast. And I still do not see why. The parts that appear commented were my attempts to fix the problem, however, they did not work. If you can help me with that, I would really appreciate it.