#include <stdio.h>
#include <stdlib.h>
typedef struct{
char *name;
char *city;
int age;
}data;
int addName(data *d){
d->name = "lady gaga";
return 0;
}
int addCity(data *d){
d->city = "new york";
return 0;
}
int addAge(data *d){
d->age = 24;
return 0;
}
int set_default(data *d){
addName(d);
addCity(d);
addAge(d);
return 0;
}
char* getName(data *d){
return d->name;
}
char* getCity(data* d){
return d->city;
}
int getAge(data* d){
return d->age;
}
int changeName(data* d, const char* name){
d->name = (char *)malloc(1*sizeof(char));
strcpy(d->name, name);
return 0;
}
int changeCity(data* d, const char* city){
d->city = (char *) malloc(1*sizeof(char));
strcpy(d->city, city);
return 0;
}
int changeAge(data* d, int age){
d->age = age;
return 0;
}
int main(int c){
system("color 5f");
data* list;
list = (data*) malloc(10*sizeof(data));
set_default(list);
printf("%s, %d of %s",getName(list), getAge(list), getCity(list));
return 0;
}
#include <stdlib.h>
typedef struct{
char *name;
char *city;
int age;
}data;
int addName(data *d){
d->name = "lady gaga";
return 0;
}
int addCity(data *d){
d->city = "new york";
return 0;
}
int addAge(data *d){
d->age = 24;
return 0;
}
int set_default(data *d){
addName(d);
addCity(d);
addAge(d);
return 0;
}
char* getName(data *d){
return d->name;
}
char* getCity(data* d){
return d->city;
}
int getAge(data* d){
return d->age;
}
int changeName(data* d, const char* name){
d->name = (char *)malloc(1*sizeof(char));
strcpy(d->name, name);
return 0;
}
int changeCity(data* d, const char* city){
d->city = (char *) malloc(1*sizeof(char));
strcpy(d->city, city);
return 0;
}
int changeAge(data* d, int age){
d->age = age;
return 0;
}
int main(int c){
system("color 5f");
data* list;
list = (data*) malloc(10*sizeof(data));
set_default(list);
printf("%s, %d of %s",getName(list), getAge(list), getCity(list));
return 0;
}
No comments:
Post a Comment