Elmenteni az outputot egy txt be /C programnyelv/?
Van ez a program...egy része mukodik de a:
fputs(' ',subor);
putc()
részét nem tudom jól elmenteni hibát is kiír a complinál.
#include <stdio.h>
#include <stdlib.h>
FILE *subor;
void writing();
void message();
int main(void)
{
int poschodie,bal1,bal2;
int spaces;
int height, i, j, k;
int priemer2,pen,pen2,pen3,pod;
writing();
scanf("%d", &poschodie);
//otvori subor
subor = fopen("stromcek.txt","w");
if(subor==NULL) {printf("\n Nepodarilo :(\n"); return -1; }
//----------------------------------------------------
printf("\n\n\n");
for (k = 1; k <= poschodie; ++k) {
height = 2 * k + 1;
spaces = 2 * poschodie;
for (i = 0; i < height; ++i) {
for (j = 0; j < spaces; ++j)
fputs(' ',subor);
for (j = 0; j < 2 * i + 1; ++j){
bal1 = rand()%3;
bal2 = bal1 % 2;
if (bal2 == 0)
putchar('*',subor);
else
fputs('0',subor);
}
fputs('\n',subor);
--spaces;
}
}
/*........................................................*/
//vykresli pen..
priemer2 = j / 2 - 1;
for (pen = 1; pen <= 3; pen++)
{
for(pen2 = 1; pen2 <= priemer2; pen2++)
{
fprintf(subor," ");
}
////////////////////////////////////////////////
for (pen3 = 1; pen3 <= 3; pen3++)
{
fprintf(subor,"*");
}
fprintf(subor,"\n");
}
for(pen3 = 1; pen3 <= priemer2 -1; pen3++)
{
fprintf(subor," ");
}
for(pod = 1; pod <= 5; pod++)
fprintf(subor,"*");
///////////////////////////////////////////////////
fclose(subor);
printf("\n\n");
void message();
return 0;
}
/////////////////////////////////////////////////////
void writing(){
printf("zadaj poschodie: ");
}
void message(){
printf("Vas vianocny stromcek bol vykresleny do suboru.");
}
valami >out.txt
hibákat:
valami 2>out.txt
#include <stdio.h>
#include <stdlib.h>
void writing();
FILE *subor;
int main(void)
{
int poschodie,bal1,bal2;
int spaces;
int height, i, j, k;
int priemer2,pen,pen2,pen3,pod;
writing();
scanf("%d", &poschodie);
//otvori subor
subor = fopen("stromcek.txt","w");
if(subor==NULL) {printf("\n Nepodarilo :(\n"); return -1; }
printf("\n\n\n");
for (k = 1; k <= poschodie; ++k) {
height = 2 * k + 1;
spaces = 2 * poschodie;
for (i = 0; i < height; ++i) {
for (j = 0; j < spaces; ++j)
printf(" ");
fprintf(subor," ");
for (j = 0; j < 2 * i + 1; ++j){
bal1 = rand()%3;
bal2 = bal1 % 2;
if (bal2 == 0){
printf("*");
fprintf(subor,"*");
}
else{
printf("0");
fprintf(subor,"0");}
}
printf("\n");
fprintf(subor,"\n");
--spaces;
}
}
/*........................................................*/
//vykresli pen..
priemer2 = j / 2 - 1;
for (pen = 1; pen <= 3; pen++)
{
for(pen2 = 1; pen2 <= priemer2; pen2++)
{
printf(" ");
fprintf(subor," ");
}
////////////////////////////////////////////////
for (pen3 = 1; pen3 <= 3; pen3++)
{
printf("*");
fprintf(subor,"*");
}
printf("\n");
fprintf(subor,"\n");
}
for(pen3 = 1; pen3 <= priemer2 -1; pen3++)
{
printf(" ");
fprintf(subor," ");
}
for(pod = 1; pod <= 5; pod++)
printf("*");
fprintf(subor,"*");
///////////////////////////////////////////////////
fclose(subor);
printf("\n\n\n");
return 0;
}
void writing(){
printf("zadaj poschodie: ");
}
ez elmenti txt ben a karacsonyfat de felbe vagva..esetleg valki latja a hibat?
Kapcsolódó kérdések:
Minden jog fenntartva © 2024, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!