0% found this document useful (0 votes)
70 views9 pages

Strings in C: Presented By, M.Sangeetha, Ap (SRG) /cse

This document discusses strings in C. It covers declaring strings using char arrays, initializing strings, reading and printing strings using functions like scanf(), printf(), gets(), and puts(). It also discusses pointers as they relate to strings, declaring pointer variables to store string addresses, and dereferencing pointers to access string values. Functions like getch(), getche(), getchar(), and getc() are also listed for working with strings.

Uploaded by

sangeetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views9 pages

Strings in C: Presented By, M.Sangeetha, Ap (SRG) /cse

This document discusses strings in C. It covers declaring strings using char arrays, initializing strings, reading and printing strings using functions like scanf(), printf(), gets(), and puts(). It also discusses pointers as they relate to strings, declaring pointer variables to store string addresses, and dereferencing pointers to access string values. Functions like getch(), getche(), getchar(), and getc() are also listed for working with strings.

Uploaded by

sangeetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Strings in C

Presented By,
M.Sangeetha,
AP(SRG)/CSE
Declaration
Char var_name[]=“string”;
char str[]=“welcome”;
Declaration
1. char str[] = “Welcome";
 2. char str[50] = “Welcome";
 3. char str[] = {‘W','e',‘l',‘c',‘o',’m',’e’,'\0'};
4. char str[14] = {‘W','e',‘l',‘c',‘o',’m',’e’,'\0'};
Example
#include<stdio.h>
  
int main()
{   
    // declaring string
    char str[50];
      
    // reading string
    scanf("%s",str);
      
    // print string
    printf("%s",str);
  
    return 0;
}
String Functions
gets() and puts()
#include<stdio.h>
int main()
{
char name[30];
printf("Enter name: ");
gets(name); //Function to read string from user. printf("Name: ");
puts(name); //Function to display string.
return 0;
}
String functions
getch()
getche()
getchar()
getc()
Pointers
datatype *variablename;
int ***ss
int **q;
int *p;
int a=20; // 2000
p=&a; //4000
q=&p; //6000
s=&q //8000
printf(“%formatspe”, q, p, *p, *q, **q, *s, a);
Contd..
a p q Variable
name
20 2000 4000 value
2000 4000 6000 address

You might also like