c - How to make flexible array that based on the input -
#include<stdio.h> #include<ctype.h> int main() { int i=0; char in[100],mychar; fgets(in,sizeof(in),stdin); while (in[i]) { mychar=in[i]; putchar (toupper(mychar)); i++; } return 0; }
simple program used change string of characters uppercase letters. question declare array in[100], how can make array number follow input? mean if type 1201 characters , program make have array follows input in[1201].
you can see c++ vector does: can malloc length of l @ fist, every time getch(), should decide if expand l 2*l (or l + 100 saving spaces)
Comments
Post a Comment