and write to it i just cant print a char variable or watever it is to it.
any help would be much apreciated
and i now my code is pretty ruf so if there are any other sugestions they would
be much apreciated.
// Go Xcode!!!!!! MeJ.J.
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
// declaring all global variables
char ch[255];
char fc[255];
char ff[255];
char te = 0;
char name[255];
// declaring all functions
void run(void);
void greetN();
void test(void);
void get_str(char *, int);
void Name();
int main(void)
{
run();
return 0;
}
void run(void) //runs everything
{
test(); //tests name for recognition
greetN(); //for new names
}
void get_str(char *buf, int buf_size)
{
int i=0;
while((i<buf_size-1) && (buf[i]=getchar()) && (buf[i] != '\n')) i++;
buf[i] = '\0';
}
void greetN()
{
cout<< "what is your Name?\n"; //
get_str(name,255);
cout<< "what is your favorit food?\n";
get_str(ff,255);
cout<< "what is your favorit color\n";
get_str(fc,255);
printf(" hello ");
cout<< name<<" don't worry I won't forget I have a photographic memory!"
<<endl<<"so if you ever need me again."
<<endl<<" tell me your name and you'l have all the imformation on what I have asked you and your answeres."
<<endl<<" I never forget anything I have a photographic memory.";
Name();
}
void test(void)
{
char buf[3];
printf("Are you new? y/n\n");
get_str(buf,3);
switch(buf[0]) {
case 'Y' :
case 'y' :
printf("type your name for Recognition\n");
break;
case'n':
case'N':
greetN();
break;
default:
printf("\ny/n");
break;
}
}
void Name()
{
FILE * pFile;
pFile = fopen (name,"w");
if (pFile!=NULL)
{
fputs ("favorit color\t%",ff,pFile);
//fputs ("favorit food\t",pFile,ff);
fclose (pFile);
}
}

New Topic/Question
Reply



MultiQuote




|