Объединить масив в строку
Есть код, который сортирует слова по количеству гласных. Проблема в том, что нужно вывести это как строку, то-есть сформировать с них строку, но я немного не понимаю как. сам код:
#include <string.h>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include <vcl.h>
#include <iostream.h>
int count_vowels(char * word)
{
int count = 0;
char vowels[] = "AEIOUYaeiouy";
for(char * p2 = word; *p2; ++p2)
for(char * p1 = vowels; *p1; ++p1)
if(*p1 == *p2)
++count;
return count;
}
int main(void)
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
string s;
char strings[10][32], str[32];
FILE *f;
int count = 0, i, j;
if((f = fopen ("file.txt", "r")) == NULL)
{
return 1;
}
while (feof(f) == 0 || count > 10)
{
fscanf (f, "%s", str);
strcpy(strings[count++], str);
}
fclose(f);
for(i = 0; i < count - 1; ++i)
{
for(j = 0; j < count - 1 - i; ++j)
{
if(count_vowels(strings[j + 1]) > count_vowels(strings[j]))
{
strcpy(str, strings[j]);
strcpy(strings[j], strings[j + 1]);
strcpy(strings[j + 1], str);
}
}
}
for(i = 0; i < count; i++)
{
printf("%s\n", strings[i]);
}
putchar('\n');
getch();
return 0;
}
Я писала через условие там, то выдает ошибку.
s+=str+" ";
if(strings[i]=='.')
s+=".";
printf(" ",s);
