Printing from a specific point in a string and onwards

I'm using C and I was wondering how you could take a text and look for a specific character and start printing only from there. Here's my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  #include <stdio.h>
#include"stdlib.h"
#include <unistd.h>
#include <string.h>
#define SIZE 1024

int main(int argc, char *argv[20])
{
    char text[SIZE];
  
    printf("Enter text");
    scanf("%s", text);

    for (int i = 0; i < SIZE; i++) {
    
        if (strcmp(text[i],"<"))
        {
            printf("%s", text[i]);
        }
    }
   
    
    return 0;

}
Last edited on
See the function strchr(...):

http://www.cplusplus.com/reference/cstring/strchr/

Note this:
If the character is not found, the function returns a null pointer.
strchr() will find the character and return a pointer to it.

because the pointer is a char* you can use it directly

1
2
3
char* txt = "this is a banana.";
char *b = strchr('b');
printf("%s",b);
Topic archived. No new replies allowed.