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 :: svg not loading in chrome 
C :: c argv 
C :: how to login to another user in powershell 
C :: ROUNDING decimal number in C 
C :: c execute shell command 
C :: C read a character 
C :: xor swap 
C :: how to make a linked list in c 
C :: how to modulo in c without % 
C :: c strcat 
C :: merge sort for strings in c 
C :: toupper function in c 
C :: c string to int 
C :: initializa 2d array c 
C :: c read file 
C :: create role in psql with password 
C :: how to convert int in to const char in c 
C :: c sizeof operator 
C :: c bubble sort 
C :: millis() 
C :: rfid rc522 code 
C :: best approach c menu terminal 
C :: how to insert elements in and array and print it in c 
C :: c list 
C :: while loop in c 
C :: rust unit test display 
C :: how to take input in c 
C :: C Syntax of return statement 
C :: spacemacs start server 
C :: anthracnose pronounce 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =