Thread: 2D- Array of Character

  1. #1
    Registered User
    Join Date
    Apr 2015
    Posts
    69

    2D- Array of Character

    Hello ,
    Could you please tell me what is wrong in this code.

    Code:
    #include <stdio.h>
    #include <string.h>
    int main(){
    	char list[5][8] = {"sankar", "sujeeth","Sravan", "Mahathi", "sanjana"};
    	char yourname[7];
    	int i, a;
    	printf ("Enter you name");
    	scanf ("%s", yourname);
    	for (i=0; i<5; i++)
    	{
    	a = strcmp(list[i][0], yourname);
    	if (a == 0)
    	printf ("Welcome , you can enter the palace\n");
    	break;
    	}
    	if (a != 0)
    	printf ("Sorry, you are a trespasser\n");
    	return 0;	
    }

  2. #2
    Registered User
    Join Date
    Feb 2012
    Posts
    347
    First parameter of strcmp should be an address.

  3. #3
    Registered User
    Join Date
    Apr 2015
    Posts
    69
    Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 07-08-2014, 08:52 AM
  2. How do I remove a character from character array?
    By nick753 in forum C++ Programming
    Replies: 25
    Last Post: 12-08-2010, 11:27 AM
  3. Replies: 15
    Last Post: 09-23-2010, 02:19 PM
  4. REmoving a character from a character array
    By Bladactania in forum C Programming
    Replies: 3
    Last Post: 02-11-2009, 02:59 PM
  5. Replies: 8
    Last Post: 11-12-2008, 11:25 AM