#include <stdio.h> #include <stdlib.h> #include<string.h> #define InfoSize 3 int main(int argc, char *argv[]) { char arr[20]; struct st { char name[20]; }; struct st info[InfoSize] = {{ "sl" },{"sos"},{"ss"}}; char s = 'ss'; for(int j=0;j<3;j++){ if(info[j].name == s ) printf("found %s ",info[j].name); }
s
struct st *pointer = &info[0];//getting pointer to address of first struct char c = 'a';//search char int pos = -1;//external scope of var for( pos = 0; pos < 50/*size of name*/; pos++ ) { if( pointer->name[pos] == c )//check break; }
char[2] s = "ss"; for(int j=0;j<3;j++){ if(strcmp(info[j].name, s) == 0 ) printf("found %s ",info[j].name);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)