PDA

View Full Version : سوال: میشه لطفا اشکال این برنامه رو بهم بگین؟



Nazari91
پنج شنبه 05 بهمن 1391, 15:11 عصر
سلام
صورت سوال این هستش که: با ++c برنامه ای بنویسید که یک فایل متنی را بخواند و حرف اول هر کلمه را بزرگ کند.(بین دو کلمه یا نقطه است یا بلنک یا کاما)

/* fseek example : This program convert first of word to Uppercase*/
#include <stdio.h>
#include<string.h>
#include<iostream.h>
#include<conio.h>

int main ()
{
FILE * pFile;
int *fp , i;
pFile = fopen ( "f://proj.txt" , "r+" );
if (pFile == NULL)
{
puts("File not Open.....");
puts("Press a key to terminate & return...");
getch();
return 0;
}
fseek ( pFile , 8 , SEEK_SET );
char ch = fgetc(pFile);
cout << ch;
getch();
fseek ( pFile , -1 , SEEK_CUR );
fputc( toupper(ch) , pFile);
ch=fgetc(pFile);
fputc(toupper(ch),pFile);

char ch;
char oldch = ch;
while ((ch=fgetc(pFile)) != EOF )
{ ch = fgetc(pFile);
if (oldch == ' ' && ch != ' ')
{

fseek ( pFile , 0 , SEEK_CUR );
fputc(toupper(ch) , pFile);
getch();
}
cout << ch << " " << fp << endl;
oldch = ch;
}

getch();
fclose ( pFile );
return 0;
}