Academic Tutorials



English | French | Portugese | Dutch | Italian
Google

em linha

Home Códigos de fonte E-Livros Downloads Contatar-nos Sobre nós

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


Cordas em C
Previous Next




Que é uma corda?

  • Uma corda é combinação dos caráteres.


  • Todo o jogo ou seqüência dos caráteres definidos dentro dos símbolos dobro da citação são uma corda constante.


  • Em c requer-se para fazer algumas operações significativas nas cordas



Cordas inicializando

A iniciação de uma corda deve o seguinte formulário que é mais simples à uma disposição da dimensão

char month1[ ]={‘j’,’a’,’n’,’u’,’a’,’r’,’y’};



O seguinte exemplo mostra o uso da corda:
/*String.c string variable*/
#include < stdio.h >
main()
{
char month[15];
printf ("Enter the string");
gets (month);
printf ("The string entered is %s", month);
}

Nota:
A corda de caráter terminou sempre por um `do caráter nulo \ 0'. Uma variável da corda sempre é declarada como uma disposição & é todo o nome válido da variável de C. O formulário geral da declaração de uma variável da corda é




Cordas da leitura do terminal:

O scanf da função com especificação do formato de %s é needed ler a corda de caráter do terminal própria. O seguinte exemplo mostra como ler cordas dos terminais:

char address[15];
scanf(%s,address);



O seguinte exemplo mostra o uso da corda:
n=strlen(string);

Onde n é a variável de inteiro que recebe o valor do comprimento da corda.




As seguintes mostras do programa para encontrar o comprimento de usar-se da corda strlen () a função
/*writr a c program to find the length of the string using strlen() function*/
#include < stdio.h >
include < string.h >
void main()
{
char name[100];
int length;
printf("Enter the string");
gets(name);
length=strlen(name);
printf("\nNumber of characters in the string is=%d",length);
}
função do strcat ():

quando você combina duas cordas, você adiciona os caráteres de uma corda à extremidade da outra corda. Este processo é chamado como a concatenação. A função do strcat () é usada a junta 2 cordas junto. Faz exame do seguinte formulário:

strcat(string1,string2)

string1 & string2 são as disposições de caráter. Quando o strcat da função é executado string2 está adicionado ao string1. a corda em string2 remanesce sempre unchanged.




função do strcmp:

Em c, você não pode diretamente comparar o valor de 2 cordas em uma condição como se (string1==string2) a maioria de bibliotecas entretanto contem a função chamada o strcmp (), que retorna um zero se 2 cordas forem iguais, ou um número non zero se as cordas não forem as mesmas. A sintaxe do strcmp () é dada abaixo:

Strcmp(string1,string2)



função do strcmpi ()

Esta função é mesma que o strcmp () que compara 2 cordas mas não caso sensíveis.

Strcmp(string1,string2)



() função strcpy:

Atribua os caráteres a uma corda, C não permite que você diretamente como no name=Robert da indicação; Instead usar () a função strcpy encontrada em a maioria de compiladores que a sintaxe da função é ilustrada abaixo.

strcpy(string1,string2);



função do strlwr ():

Esta função converte todos os caráteres em uma corda de caixa ao lowercase

A sintaxe do strlwr da função é ilustrada abaixo

strlwr(string);



função do strrev ():
Esta função inverte os caráteres em uma corda particular. A sintaxe do strrev da função é ilustrada abaixo
strrev(string);



O seguinte programa ilustra o uso de funções da corda:
/* Example program to use string functions*/
#include < stdio.h >
#include < string.h >
void main()
{
char s1[20],s2[20],s3[20];
int x,l1,l2,l3;
printf("Enter the strings");
scanf("%s%s",s1,s2);
x=strcmp(s1,s2);
if(x!=0)
{printf("\nStrings are not equal\n");
strcat(s1,s2);
}
else
printf("\nStrings are equal");
strcpy(s3,s1);
l1=strlen(s1);
l2=strlen(s2);
l3=strlen(s3);
printf("\ns1=%s\t length=%d characters\n",s1,l1);
printf("\ns2=%s\t length=%d characters\n",s2,l2);
printf("\ns3=%s\t length=%d characters\n",s3,l3);
}




Previous Next

Keywords: Strings in C, strings in c++, string in c, string functions in c, strcmp in c, integer to string in c, array of strings in c, int to string in c, string quartet in c sharp minor, string manipulation in c, string concatenation in c, string array in c, string quartet in c minor, string compare in c


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.