Santa's little helper
Fledgling Freddie
- Joined
- Dec 22, 2003
- Messages
- 352
Wish i knew C++ I'm currently learning Java.
Can anyone recommend books?
Can anyone recommend books?
Anyway, scanf() will happily read a "string" in to your buffer for you to then strcmp. Or you may want to read 1 char at a time to ensure you don't buffer overrun. As you can't do a switch on a char* you may prefer to use atoi() to convert the "123" to an integer 123.
struct Node {
int value;
struct Node *next;
};
struct Node {
char *value;
struct Node *next;
};
printf("Value: %s\n", node->value);
struct Node {
int* ptr;
struct Node* next;
}
realValue = (int)*ptr;
char* string = (char*) *ptr;
...
...
...
char value[10];
struct node
{
char data;
struct node *next;
}; typedef struct node *listpointer;
void main()
{
listpointer list;
list = NULL;
list = (listpointer) malloc (sizeof (struct node));
printf("Please enter an initial value");
gets(value);
strcpy(list->data, value);
printf("\nFirst data item is %s\n", list -> data);
}
void add( struct node *new )
{
if( head == NULL )
head = new;
end->next = new;
new->next = NULL;
end = new;
}
if(strcmp(value, arrive) == 0)
{
printf("Enter in name -- ");
scanf("%s", data );
ptr = initnode(data);
add(ptr);
}