I write this program to cheak user name and password enter by the use is same then the user is able to login,
for this i declare a pointer array to store some user name and password (like sin up by user),and then the user enter her user name and password , i use string compare function to find the weather the enter username and password is correct
But at run time this code give an error

#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main()
{
    char *cUser[5],*cPassword[5],cLoginU[10],cLoginP[10];
    int iCount=0,iUser,iPass;
    do
    {
        printf("Enter the user name :");
        scanf("%s",&cUser[iCount]);
        printf("Enter the user password :");
        scanf("%s",&cPassword[iCount]);
        iCount++;    
    }while(iCount<5);
    printf("\nEnter the username for login : ");
    scanf("%s",&cLoginU);
    printf("\nEnter the password for login : ");
    scanf("%s",&cLoginP);
    for(iCount=0;iCount<5;iCount++)
    {
        iUser=strcmpi(cUser[iCount],cLoginU);
        if(iUser==0)
        {
            break;
        }
    }
    for(iCount=0;iCount<5;iCount++)
    {
        iPass=strcmp(cPassword[iCount],cLoginP);
        if(iPass==0)
        {
            break;
        }
    }
    if(iUser==0 && iPass==0)
    {
        printf("\nYour Login successful");
    }
    else
        printf("\nWrong username and password");
    getchar();
    return 0;
}

>> char *cUser[5]
That declares an array of 5 pointers. Are you attempting to store 5 different use names in that array? If you are, then you have to allocate memory for them before they can be used. There are a couple ways to do it

1) use static allocation, such as char cUser[5][25]; which will have enough space for 5 user names, each name as maximum of 24 characters + null terminator.

2) allocate them with malloc

for(i = 0; i < 5; i++)
   cUser[i] = malloc(25);

The same applies to cPasssword.

But for the life of me I don't know why you would want to user to enter 5 differet user names and passwords? Why not just one ?

i use 5 user name because their are 5 different user who sin up and when one user enter his user name and password the the code compare the username and password withe the existing username and password...

I make some correction as you said but it still gave an runtime error!!!!!!!!!

#include<conio.h>
    #include<stdlib.h>
    #include<stdio.h>
    #include<string.h>
    int main()
    {
    char cUser[5],cPassword[5],cLoginU[10],cLoginP[10];
    int iCount=0,iUser,iPass;
        for(iCount = 0; iCount < 5; iCount++)
            cUser[iCount] = malloc(25);
        for(iCount = 0; iCount < 5; iCount++)
            cPassword[iCount] = malloc(25);
    iCount=0;
        do
    {
    printf("Enter the user name :");
    scanf("%s",&cUser[iCount]);
    printf("Enter the user password :");
    scanf("%s",&cPassword[iCount]);
    iCount++;
    }while(iCount<5);
    printf("\nEnter the username for login : ");
    scanf("%s",&cLoginU);
    printf("\nEnter the password for login : ");
    scanf("%s",&cLoginP);
    for(iCount=0;iCount<5;iCount++)
    {
    iUser=strcmpi(cUser[iCount],cLoginU);
    if(iUser==0)
    {
    break;
    }
    }
    for(iCount=0;iCount<5;iCount++)
    {
    iPass=strcmp(cPassword[iCount],cLoginP);
    if(iPass==0)
    {
    break;
    }
    }
    if(iUser==0 && iPass==0)
    {
    printf("\nYour Login successful");
    }
    else
    printf("\nWrong username and password");
    getchar();
    return 0;
    }

You made incorrect changes. Delete the allocations on lines 9 thru 12 and just hard code their sizes char cUser[5][10], cPassword[5][10]; Since cLoginU is declared to contain only 10 characters, then cUser should be the same size.

can u tell me why u use cUser[5][10]
why not *cUser[5]
what is the advantage to use the cUser[5][10]????????????

???????????????????????????

can u tell me why u use cUser[5][10]
why not *cUser[5]
what is the advantage to use the cUser[5][10]????????????

One of the best methods to turn people off from helping you in a high tech forum is to write like a "valley-girl-teenager" in a phone text messaging session. Avoid the sticky-key syndrome and use correct English.
After that, you exercise patience.

There is no point in dynamically allocating small amounts of memory. One advantage of usiong cUser[5][10] is that is is not prone to memory leaks.

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.