Horje
string in c Code Example
strings in c
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#define MAX_LENGTH 100
#define NUM_STRINGS 10

int main(){

    char arr[NUM_STRINGS][MAX_LENGTH] = {""};

    arr2[0] = "string literal"; // Not permitted
    strcpy(arr[0], "hello world");
    printf("%s\n", arr[0]);
    printf("%s\n", strcpy(arr[0], "hello world"));

    exit(EXIT_SUCCESS);
}
string in c
#include<stdio.h>
void main(){
    int date;
    char fn[50], ln[50];
    printf("Enter your first name = ");
    scanf("%s",&fn);
    printf("Enter your last name = ");
    scanf("%s",&ln);
    printf("Enter your year of birth = ");
    scanf("%d",&date);
    printf("Your first name = %s\nlast name = %s\nand year of birth = %d", fn, ln, date);
}
string in c and how it works
Strings are defined as an array of characters. The difference between a 
character array and a string is the string is terminated with a special
character ‘\0’.




C

Related
print 0 1 2 3 4 in c while loop Code Example print 0 1 2 3 4 in c while loop Code Example
bubble sort in C Code Example bubble sort in C Code Example
C special character display Code Example C special character display Code Example
sum of arrays Code Example sum of arrays Code Example
how to input n space separated integers in c Code Example how to input n space separated integers in c Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9