Hi again im a new comer im from Jamaica, i have an assugnment due wednesday and im trying to make my project look proffessional, in C there is a keyword called struct and im familiar with using structures, i was just wondering is there anyway to search for strings or characters within a structure?

Sure there is!

You can use strchr() to look for a char in the string, or strstr() to look for a sub string in the string, same as if your char array was outside the struct.

There is no difference, except you need to use the dot operator to access the struct member:

#include <stdio.h>
#include <string.h>  //needed for strstr() or strchr()

struct myStruct{
  char firstName[20];
  int age;
  //etc.
}mystruct1;

int main() {
  //using the dot operator for a simple char array print:
  printf("\n%s ", mystruct1.firstName); 
  return 0;
}

If you're stuck on this, post up your code, and let's see what you're stuck on.

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.