Showing posts with label C Strings. Show all posts
Showing posts with label C Strings. Show all posts

Saturday, October 24, 2026

Strings in C Language Functions Example in Telugu Part-9 | LearnTechSoft

Strings in C Language | Full Guide in Telugu

Part-9: C lo peru ela store cheyali? - LearnTechSoft

💡 Real Life: C lo int ante numbers ke, char ante okka letter ke. Mari "Ramesh" lanti peru ela? Adhe String! Chala characters kalipi okate String.

1. String ante enti?

String = Character Array + \0 (Null Character) - Prati string chivarlo \0 automatic ga untundi - Adhe string end ayyindi ani C ki telsedi.

R A M E S \0
Index: 0 | 1 | 2 | 3 | 4 | 5 (Null)

2. String Declaration

// Method 1: Best Method
char name[] = "Ramesh";

// Method 2: Size tho
char name[20] = "Ramesh";

// Method 3: Character by character
char name[7] = {'R','a','m','e','s','h','\0'};

// Print: 
printf("%s", name); // %s for String

3. String Input - Important Difference!

⚠️ 2 Methods:
scanf("%s"): Oka word ke - "Ramesh Kumar" lo "Ramesh" matrame teesukuntundi (Space vaste aagipotundi)
gets() / fgets(): Full line - "Ramesh Kumar" motham teesukuntundi
char fullName[50];

// For full name with space:
printf("Enter Full Name: ");
fgets(fullName, 50, stdin); // Best & Safe

printf("Hello %s", fullName);

4. Important String Functions - Library

Include cheyali: #include <string.h>

FunctionPanienti?Example
strlen()Length kanukkodanikistrlen("Ramesh") = 6
strcpy()Copy cheyadanikistrcpy(a, b)
strcat()Jodinchadaniki"Ram"+"esh" = "Ramesh"
strcmp()Compare cheyadanikiEqual ayithe 0 vastundi
#include <stdio.h>
#include <string.h>

int main() {
    char name1[20] = "Ramesh";
    char name2[20] = " Kumar";
    
    printf("Length: %d\n", strlen(name1)); // 6
    
    strcat(name1, name2); // Jodinchi
    printf("Full Name: %s\n", name1); // Ramesh Kumar
    
    return 0;
}

🎯 Next Post: Pointers in C - Most Difficult but Important - Part-10

Practice: Name reverse, Palindrome check, Length without strlen()

Abstraction in Java - Explained in Simple Words with Examples in Telugu | LearnTechSoft Abstraction in Java - Explained in Simpl...