Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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; 
} 
 
PREVIOUS NEXT
Tagged: #print #character #string
ADD COMMENT
Topic
Name
3+9 =