Search
 
SCRIPT & CODE EXAMPLE
 

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

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]
Comment

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])
}
Comment

PREVIOUS NEXT
Code Example
C :: fwrite in c 
C :: c convert float to string 
C :: round float in c 
C :: why there is return 0 used in c 
C :: form controls in bootsrap 
C :: how to compareTo in java 
C :: c sizeof operator 
C :: syntax 
C :: sort names in array in c 
C :: binary search tree of strings in c 
C :: millis() 
C :: how to empty array in c 
C :: recursive in c 
C :: how to run c program from visual studio terminal 
C :: open with overwrite c 
C :: getchar c 
C :: yum install supervisor amazon linux 
C :: binary sorting 
C :: Find the how many bits is turned on in a numebr 
C :: c function definition 
C :: getchar declaration in c 
C :: linux_reboot_magic2 
C :: sOY wapo ya lo c 
C :: how to do Employing defensive code in the UI to ensure that the current frame is the most top level window 
C :: check if a number is even and bigger than or equal to 16 using bitwise 
C :: konami code hdl 
C :: overhead computer science 
C :: c programming print pattern pyramid 
C :: write a c program to find out ncr factor of given number 
C :: get file ligne count c 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =