Please Help me fix this

+1 Ash Marz · November 22, 2014

#define MYNAME "Supachai Abusali"
#define CLASS "Teenager"
#define AGE 18

this is my MyInfo.h file 

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

int main()
{

  char cat = "bengal tiger";
  printf("%s is who is a %s and %d bought a %s ", MYNAME,CLASS,AGE,cat);

    return 0;
}

PLease help me fix this code it is not working

Post a Reply

Replies

Oldest  Newest  Rating
0 Franz Schmidt · November 22, 2014
Your problem is the "cat" - string 
A string contains of multiple characters but your variable only can save ONE char so you can't save a complete string in it.

To solve this problem you only need to make a char-array instead of a simple char variable.

char cat[] = "bengal tiger";
0 Teemmy Ellorry · November 23, 2014

#include <stdio.h>
#include <stdlib.h>
#define MYNAME "Supachai Abusali"
#define CLASS "Teenager"
#define AGE 18

int main()
{
  char cat[] = "bengal tiger";
  printf("%s is who is a %s and %d bought a %s ", MYNAME,CLASS,AGE,cat);

    return 0;
}
  • 1

C

107,162 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator