Jump to content
Hostul a fost schimbat. Daca vedeti serverul offline readaugati rpg.b-zone.ro sau 141.95.124.78:7777 in clientul de sa-mp ×

[C++] Numarul de caractere


Jackson Brooklyn
 Share

Recommended Posts

Am revenit cu un nou cod, simplu, foarte simplu.

 

#include<iostream>
#include<stdio.h>
using namespace std;
int main( )

{

char str[80];
int i = 0;
cout<<"Adauga un string : ";
gets(str);
for(i=0;str[i]!='\0';i++);
cout<<"Lungimea string-ului este : "<<i;
return 0;

}

Ce face codul? numara toate caracterele din propozitia voastra INCLUSIV CARACTERELE GOALE si va spune cate sunt :)

Link to comment
Share on other sites

Ceva foarte important a fost evidentiat in acest tutorial:

Un sir de caractere se termina cu "\0". Acesta este un lucru destul de folositor atunci cand lucrezi cu C

:topic_closed:

Edited by Cdorsu
Link to comment
Share on other sites

  • Cdorsu locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.