Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 458
  • Last Modified:

Errors

Can someone quickly fix the errors in the following for me:


typedef unsigned int size_t;
typedef struct {
int      _file;                  int      _flag;                  unsigned _bufsiz;            char      *_ptr;                  int      _cnt;                  char      *_base;            } FILE;
extern      FILE _files[32];
FILE *fopen(char *name, char *mode);
int   fclose(FILE *fp);
int   fread(void *buf, int sizelem, int n, FILE *fp);
int   fwrite(void *buffer,int sizelem, int n,FILE *fp);
int   feof(FILE *fp);
int   ferror(FILE *fp);
int   fflush(FILE *fp);
void  clearerr(FILE *fp);
int   fseek(FILE *fp,long offset,int origin);
long  ftell(FILE *fp);
int   fscanf(FILE *fp,char *format,...);
int   scanf(char *format,...);
int   sscanf(char *buf, char *fmt, ...);
int   fprintf(FILE *fp, char *fmt, ...);
int   printf(char *fmt, ...);
int   sprintf(char *buf, char *fmt, ...);
int   vsprintf(char *buf, char *fmt, char *args);
int   fgetc(FILE *fp);
char *fgets(char *buf, int n, FILE *fp);
int   getc(FILE *fp);
int   getchar();
char *gets(char *buf);
int   ungetc(int c, FILE *fp);
int   fputc(int c, FILE *fp);
int   fputs(char *str, FILE *fp);
int   putc(int c, FILE *fp);
int   putchar(int c);
int   puts(char *str);
int main(void)
{
printf("%d = in us dollars"\n);
printf("%d australian = 0.701740 %f usd"\n);
printf("what amount is austrailia"\n);
printf("%d jamaican = 60.0500 %f usd"\n);
printf("what amount is jamaican"\n);
printf("%d african = 545.872 %f usd"\n);
printf("what amount is african franc"; \n)
printf("%d bahamas = 1.00000 %f usd"\n);
printf("what amount is bahamas"\n);
printf("%d germany = 0.832159 %f usd"\n);
printf("what amount is germany"\n);
printf("rates as of august"\n);  
return 0;
0
objects
Asked:
objects
  • 3
  • 2
  • 2
  • +3
5 Solutions
 
avizitCommented:
1. why are you writing the prototypes of all the standard functions , you can just include the <stdio.h>

2. You need to read up more. The printf function is not used the way you are using.

e. g of correct usage

printf("Hey");

this will print Hey  

printf("hey\n");

this will print hey and also append a new line at the end

printf("an example of an integer is %d",12);

this will print an example of an integer is 12

overall you need to get a good C book and study and start from scratch as in from the
"hello world" program.

0
 
sunnycoderCommented:
#include<stdio.h>
int main(void)
{
printf("%d = in us dollars\n");
printf("%d australian = 0.701740 %f usd\n");
printf("what amount is austrailia\n");
printf("%d jamaican = 60.0500 %f usd\n");
printf("what amount is jamaican\n");
printf("%d african = 545.872 %f usd\n");
printf("what amount is african franc \n");
printf("%d bahamas = 1.00000 %f usd\n");
printf("what amount is bahamas\n");
printf("%d germany = 0.832159 %f usd\n");
printf("what amount is germany\n");
printf("rates as of august\n");
return 0;
}

%d, %f etc in printf are format specifiers ... you need to supply the variables/data whose format you are specifying ... something like
printf("%d germany = 0.832159 %f usd\n"1,0.5);
or
printf("%d germany = %f usd\n"1, 0.832159);
or using variables
printf("%d germany = 0.832159 %f usd\n"ger,ger*0.832159);
ofcourse you need to declare and initialize ger before using it
0
 
ssnkumarCommented:
What is the problem statement?

-ssnkumar
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
lwinkenbCommented:
I think sunny missed some commas in his printf examples.
printf("%d germany = 0.832159 %f usd\n"1,0.5);
should be
printf("%d germany = 0.832159 %f usd\n",1,0.5);
(notice the comma after the second pair of quotes).


0
 
ankuratvbCommented:
Hey,

its objects of Java fame.

In addition to the above comments,You might need to get input from the user.

For that you'll need to use scanf().

The syntax is pretty similar to  printf.

int i;
scanf("%d",&i);

To print the value of i,use printf("Value of i:%d",i);
0
 
objectsAuthor Commented:
Thanks people, and apologises for my laziness :)
0
 
sunnycoderCommented:
>I think sunny missed some commas in his printf examples
good catch lwinkenb ...

hey objects,
this might interest you
http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_21078242.html
0
 
lwinkenbCommented:
Here is a little example to get you started in the right direction objects...

#include <stdio.h>
#include <stdlib.h>

int main()
{
      char buff[64];
      float fDollars_us;

      printf("Program starting...\n");
      printf("How many dollars in US currency?:  ");
      gets(buff);
      fDollars_us = (float)atof(buff);
      printf("\nYou entered in %f US dollars\n",fDollars_us);
      printf("In Australian this is %f\n", fDollars_us * 0.701740f);

      return 0;
}
0
 
objectsAuthor Commented:
I've lot all I need, thanks all :)
0
 
sunnycoderCommented:
for the umpteenth time ;o)

*dont* use gets ... use fgets instead ....
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now