Quote:
Originally Posted by jurmav
the i have here is:
#include<stdio.h>
#include<string.h>
#define p printf
main()
{char a;
clrscr();
p("input a word: ");
scanf("%s",a);
printf("\n you entered a character");
getch();
}
i don't know what will be the next step.
This is no good.
instead of a single char you need a array of chars.
There are two types of arrays in c:stack arrays and dynamic arrays.
Size of stack array cannot be changed during execution,which is not true for dynamic arrays.To build a dynamic array(you don't know size of the string that user will enter) you just declare a pointer to a char:
char *a.*b;/*You will need 2 arrays
If you want to capture a whole sentence not just a part of the string(scanf breakes on a white space) you use gets() to read in a string.After that you can use strlen to determine the size of first array and the allocate second one:
b=(char*)malloc(sizeof(char)*(strlen(a)+1))
Now you can use as a simple stack based arrays.When you have done this post again.
PS:It's recomended that you read some tutorials about arrays.
Savage