Nios/structstore
From ASMBits
nios/squarePrevious
Nextnios/structfind
Consider the following struct:
struct Codes {
char postal_code[7];
unsigned short area_code;
};
Write a function that will write to a given entry of an array of struct Codes. The first two function parameters specify the beginning of the array of structs and which array element to modify (index=0 is the first array element). The third and fourth parameters provide the new value of the postal_code and area_code fields.
You are guaranteed that postcode is a null-terminated string of no more than 6 characters (not including the NULL). Ensure the postal_code is also null-terminated (but do not modify any bytes after the null).
void set_data (struct Codes* array, int index, char *postcode, unsigned short areacode);
Expected solution length: Around 10 lines.
Sample Input
Write {"N2L3G1",519} into { {"M5S3G4",416}, {"V6T1Z4",604}, {"K7L3N6",613} } at position 1
Sample Output
{ {"M5S3G4",416}, {"N2L3G1",519}, {"K7L3N6",613} }
nios/squarePrevious
Nextnios/structfind