istringstream iss(line); int n = 0; while (!(iss >> dat[n]).fail()) n++; 转载于:https://www.cnblogs.com/jluzhsai/p/3256276.html