Coding in C -confused about scanf and pointers

Discussion in 'OT Technology' started by awns729, Sep 29, 2008.

  1. awns729

    awns729 New Member

    Joined:
    Jan 4, 2008
    Messages:
    353
    Likes Received:
    0
    I'm doing this CS project and have a bunnnnch of scanf questions and possible a pointer question...

    Can someone give me an example of how to use scanf to search a string and return t/f depending on whether it contains certain characters or not?

    I thought this would work

    printf("%d", scanf("%[A-Za-z]", "23434H"); //print 1 and without the H print 0
    based on my notes, but clearly I'm missing somethig significant.
    I'll have many more questions later :)
    thanks

    EDIT: trying to do this without ANY user input. thanks
     
    Last edited: Sep 29, 2008
  2. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    scanf is used to read input, so wrong function.
    You want to use strpbrk or strtok.
     

Share This Page