kensy11
asked on
how can i store data in to a array
hallo,
im trying to put data in to array its a name
but i dont know how
please help.
im trying to put data in to array its a name
but i dont know how
please help.
#include <stdio.h>
#include <conio.h>
int main (void)
{
char vnaam[50];
printf("Wat is u voornam ?");
scanf("%s",vnaam[50]);
getchar();
printf("well look %s",vnaam[50]);
getchar();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks my code looks like this
i have another question what if i dont know how long the array will be, now its 50 but can just leave it blank ?
i have another question what if i dont know how long the array will be, now its 50 but can just leave it blank ?
#include <stdio.h>
#include <conio.h>
int main (void)
{
char vnaam[];
printf("Wat is u voornam ?");
scanf("%s",vnaam);
getchar();
printf("well look %s",vnaam);
getchar();
}
>> char vnaam[];
Sorry, this is not valid. If you are filling up an array with scanf, you should make it much larger than any possible entry. After the entry, it will be null terminated.
Sorry, this is not valid. If you are filling up an array with scanf, you should make it much larger than any possible entry. After the entry, it will be null terminated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'm not sure about scanf function but I remember that cin function in C++ takes 512 characters, not more.
Open in new window