Question: Please modify this source code so that it is written in C instead of C++. I am looking for the same output. Source code: #include
Please modify this source code so that it is written in C instead of C++. I am looking for the same output.
Source code:
#include
#include
#include
using namespace std;
int main()
{
vector
vector
string title, header1, header2,s;
cout
getline(cin,title);
cout
cout
getline(cin,header1);
cout
cout
getline(cin,header2);
cout
while(true){
cout
getline(cin,s);
if(s == "-1"){
break;
}
else{
int commaCount = 0;
for(int i=0; i if(s[i] == ',') commaCount++; } if(commaCount == 0){ cout } else if(commaCount > 1){ cout } else{ string firstWord = s.substr(0, s.find(",")); string secondWord = s.substr(s.find(",")+1, s.length()-1); firstWord.erase(0, firstWord.find_first_not_of(' ')); secondWord.erase(0, secondWord.find_first_not_of(' ')); int countNumbers = 0; for(int i=0; i if(secondWord[i] >='0' && secondWord[i] countNumbers++; } } if(countNumbers == secondWord.length()){ dataPoint.push_back(atoi(secondWord.c_str())); //dataPoint.push_back(stoi(secondWord)); dataStr.push_back(firstWord); cout cout } else{ cout } } } } cout cout cout for(int i=0; i cout } cout for(int i=0; i cout for(int j=0; j cout } cout } return 0; } 



Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
