Get First Character From String C

[Solved] Get First Character From String C | Swift - Code Explorer | yomemimo.com
Question : how to print the first character of a string in c

Answered by : abdullah-miraz

#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;
} 

Source : | Last Update : Fri, 16 Apr 21

Question : c check first character of string

Answered by : md-mursalatul-islam-pallob

// c char str[](single string)
array[0]
// c char str[] (multiple string)
array[0][0]
// c++ std::stirng s;
s[0]

Source : | Last Update : Sun, 25 Apr 21

Question : c check first character of string

Answered by : vscoder

#include <stdio.h>
int main(void){ char b[5]; scanf("%s",&c); printf("Simple answer %c",b[0:4])
}

Source : | Last Update : Fri, 30 Apr 21

Answers related to get first character from string c

Code Explorer Popular Question For Swift