Overwrite the newline character in string : String Terminator « String « C Tutorial

Home
C Tutorial
1.Language
2.Data Type
3.String
4.printf scanf
5.Operator
6.Statement
7.Array
8.Function
9.Structure
10.Pointer
11.Memory
12.Preprocessor
13.File
14.Data Structure
15.Search Sort
16.Wide Character String
17.assert.h
18.ctype.h
19.math.h
20.setjmp.h
21.signal.h
22.stdio.h
23.stdlib.h
24.string.h
25.time.h
26.wctype.h
C / ANSI-C
C++
C++ Tutorial
Visual C++ .NET
C Tutorial » String » String Terminator 
3.2.2.Overwrite the newline character in string
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
  char text[100];                

  printf("\nEnter the string to be searched(less than 100 characters):\n");
  fgets(text, sizeof(text), stdin);

  text[strlen(text)-1'\0';

  printf("%s",text);

}
Enter the string to be searched(less than 100 characters):
     string
     string
3.2.String Terminator
3.2.1.Displaying a string with a string terminator in the middle
3.2.2.Overwrite the newline character in string
3.2.3.By setting first[4] to NULL ('\0'), we can shorten the string
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.