Post Reply  Post Thread 
Brojanje znakova
Author Message
Len0
Redoviti posjetitelj
**


Posts: 242
Group: Registered
Joined: Mar 2007
Status: Offline
Reputation: 2
Post: #1
Brojanje znakova

Kako mogu da korisniku za unesenu riječ ili rečenicu ispisem broj znakova koje zauzima ta riječ, da broji i blanko znakove???
Naravno za consolne programe.


RTFM - Rich Text Format Manual
05-10-2007 04:41 PM
Find all posts by this user Quote this message in a reply
Puž
Redoviti posjetitelj
**


Posts: 131
Group: Registered
Joined: Mar 2007
Status: Offline
Reputation: 24
Post: #2
RE: Brojanje znakova

Nisi rekel dal ti treba za C/C++ ili za C#. Evo ti oba primjera.

c/c++

Code:
#include <iostream>
using namespace std;
#include <stdio.h>


int main()
{
    char rijec[50]="";
    int dulj;
    
    cout <<"zadajte rijec:\n";
    gets(rijec);
    
    dulj=strlen(rijec);

    cout <<dulj<<"\n";

    getchar();
    getchar();
    return 0;
}


c#

Code:
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string rijec;
            int dulj;

            Console.WriteLine("zadajte rijec:");
            rijec = Console.In.ReadLine();

            dulj = rijec.Length;
            Console.WriteLine(dulj);
        }        
    }
}

07-10-2007 01:53 PM
Find all posts by this user Quote this message in a reply
Len0
Redoviti posjetitelj
**


Posts: 242
Group: Registered
Joined: Mar 2007
Status: Offline
Reputation: 2
Post: #3
RE: Brojanje znakova

Hvala, trebalo mi je za C++.


RTFM - Rich Text Format Manual
07-10-2007 02:16 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: