Comparing one string and one string from an array of strings in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kosvid
    New Member
    • Dec 2015
    • 1

    Comparing one string and one string from an array of strings in C

    //What i am doing wrong in the strcmp line!I still cant understand it and i am here for so many hours!Help

    The compiler doesnt give me any errors or warnings

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #define SIZEX 45
    
    
    int main() {
    	
    	char *a[50][7];
    	a[0][4]="kosvid";
    	int flag=0;
    	int x;
    	char z[10];
    	
    	printf("Please enter the username \n");
        scanf("%s",z);
    
    	for(x=0;x<=SIZEX;x++)
    	         {
    	        	if(strcmp(a[x][4],z)==0)
    		        {
    			        flag=1;
    		        }
    	        }
    	        
    	        
    	return 0;
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Code:
     a[0][4]="kosvid";
    Read this: https://bytes.com/topic/c/insights/7...rrays-revealed

    And then tell me what you think this code does.

    Comment

    Working...