void setBusShift(bus_shift* bs, char* line, std::map<std::string, int> *powerMap) { int len = lineLen(line, " "); bs->len = len - 1; bs->s = (int*)malloc(sizeof(int) * bs->len); bs->e = (int*)malloc(sizeof(int) * bs->len); bs->pc = (int*)malloc(sizeof(int) * bs->len); setShiftData(bs, line, powerMap); }
/* Revise the main routine of the longest-line program so it will correctly print the length of arbitrarily long input lines, and as much as possible of the text */ int main(){ int len; /* current line length */ int max; /* maximum length seen so far */ char line[MAXLINE]; /* current input line */ char longest[MAXLINE]; /* longest line saved */ max = 0; while((len = lineLen(line, MAXLINE)) > 0) if(len > max){ max = len; copy(longest, line); } if(max > 0){ printf("\n\nThe longest line was:\n%s", longest); } return 0; }