Answers for "c check first character of string"

C
1

how to print the first character of a string in c

#include <stdio.h> 
#include<string.h> 
 
int main(void)  
{ 
	char c[100]; 
	scanf("%s",c); 
	/*strlen(c) gives total length of string . string index starts from 0 
	last index of character is strlen(c)-1*/ 
	int l = strlen(c)-1; 
	printf("%c %c",c[0],c[l]); 
	return 0; 
}
Posted by: Guest on April-09-2021
1

c check first character of string

// c char str[](single string)
array[0]
// c char str[] (multiple string)
array[0][0]
// c++ std::stirng s;
s[0]
Posted by: Guest on April-18-2021
1

c check first character of string

#include <stdio.h>

int main(void){
  char b[5];
  scanf("%s",&c);
  printf("Simple answer %c",b[0:4])
}
Posted by: Guest on April-23-2021

Code answers related to "c check first character of string"

Code answers related to "C"

Browse Popular Code Answers by Language