can i return a value using CHAR DATA TYPE? NOT INT?
ex.int data;
int value(ex.data)
return data;
how about this
ex.char name;
int(ex.name)
return name;
possible or not?

Recommended Answers

All 6 Replies

Yes

char GetChar()
{
   return 'a';
}

or

char GetChar(int iValue)
{
   return (char) iValue; //there can be side-effects if the value is outside of the range.
}

how about in link list may i use that?i need to store strings. my problem is i cannot solve my problem in strings can u help me? =))

What do you mean?
Yes, you can store a char in a linked list.

What are you trying to do?
I should not guess at potential solutions when I don't know the actual problem.

Is this the same question?

HERE HOW TO store strings in this list
>_<
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define p printf
#define s scanf
struct node
{
char nbook;
struct node *next;
};
typedef struct node *nodepointer;
void addbook(nodepointer &head,char book[50])
{
nodepointer newnode;
newnode=(nodepointer)malloc(sizeof(struct node));
newnode->nbook=book[50];
newnode->next=head;
head=newnode;
}
void display(nodepointer head)
{
if(head==NULL)
{
p("\nNothing to display");
}
else if(head!=NULL)
{
while(head->next!=NULL)
{
p("\n%s",head->nbook);
head=head->next;
}
p("\n%s",head->nbook);
}
}
main()
{
nodepointer head=NULL;
int choice;
char book[50];
do
{
p("\n[1]Add book");
p("\n[2]Display book");
p("\nKey choice: ");
s("%i",&choice);
switch(choice)
{
case 1:
p("\nEnter title of book");
s("\n%s",&book);
addbook(head,book);
break;
case 2:
display(head);
break;
}
}while(choice!=4);
system("pause");
}

Please don't post the same question multiple times.
Please use code tags to make code easier to read.
Please search the site for example of common homework problems and solutions like linked lists.

im sorry im new here >_<.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.