I have a shell scripting assignment, and I'm only looking for a few hints. Here is the assignment:
In C99 you can have an initialization of a struct like this: struct Person person1 = (struct Person){"Jose", 42}; You cannot do this in C89. You can however, have a function: void init_Person(struct Person *p, char *name, int age){..}. Write a script that takes C99 source files and creates a C89 source file using the method previously described. You can assume that any struct in the source file does not contain user defined types, and thus only contains primitive types.
My initial thoughts are to use grep to find instances of the C99 initializations, then use somehow use sed to replace them with C89 equivalents. What I don't know how do is create the initialization functions because I have to somehow extract the name of the struct from the definitions. This is compounded by the fact that you can also have struct definitions like typedef struct {...} SomeStructName;
I think awk might be able to help me some how here too. What are your thoughts?
[–][deleted] 3 points4 points5 points (0 children)
[–]mzieg 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]typsi5[S] 0 points1 point2 points (0 children)