#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
using namespace std;
int main()
{
FILE *fp;
vector <const char*> v;
char vchar[100];
fp = fopen("lab5.in", "r");
while (fgets(vchar, 99, fp))
{
vchar[strlen(vchar) - 1] = 0;
v.push_back(vchar);
}
cout << "\n";
for (int i = 0; i < v.size(); i++)
cout << v[i] << " ";
fclose(fp);
return 0;
}
I have the above code.
asd
fsa
def
And the above lab5.in file.
In code:blocks
Expected output: asd fsa def Actual output: def def def
In Visual Studio: I get "Debug assertion failed" error, no output. I have #include "stdafx.h" in visual studio added.
Could you please help me?
Aucun commentaire:
Enregistrer un commentaire