SlideShare a Scribd company logo
1 of 7
СТРИНГОВИ
У програмском језику C++ постоји тип података string који
садржи текст.
За рад с низом знакова може се користити тип string или
char.
Тип string се користи у случају када се ради с ријечима или
реченицама, док тип char само када се ради са једним
знаком (а ту врсту промјењиве ћемо користити у 9. разреду
кад будете научили низове-поља и цикличне алгоритамске
структуре, наредбу for).
При раду с типом string на почетку програма потребно је
извршити декларацију промјењиве наредбом:
string ime_promjenjive;
За учитавање стринга до размака(једна ријеч) користи се
наредба cin а за исписивање стринга на екран користи се
cout наредба из датотеке iostream.
Примјер1: Напишите програм ”IME” који исписује
унесени текст.
УЛАЗ
ИЗЛАЗ
Примјер2:
Напишите програм ”IME I PREZIME” који исписује унесени текст.
"Спајање" два стринга
Два стринга(ријечи), или више њих се могу спојити користећи
операцију сабирања "+" као што смо радили сабирајући бројеве.
УЛАЗ
ИЗЛАЗ
ОБРАДА
Уколико желимо да унесемо цијелу линију текста - реченицу
морамо користити функцију
getline(cin, ime_varijable);
Примјер3:
Напишите програм који исписује унесени текст.
Дужина стринга
Слова, размаци, знаци интерпункције и сви остали знаци који се
користе у рачунару називају се карактери. Да бисмо добили број
карактера у неком стрингу користимо функцију length () или
size().
Примјер4: Напиши програм који исписује дужину унесеног
текста.
Можемо издвојити дио стринга функцијом substr.
Ова функција не уклања подстринг из оригиналног стринга; умјесто
тога, она креира нови стринг који садржи одређени подстринг
датог оригиналног стринга (издваја дио ријечи или реченице).
Тражени подстринг је одређен почетном позицијом и бројем
карактера тј. дужином, узимајући у обзир да је позиција почетног
карактера стринга 0.
Примјер: Marica
Од позије 2 издвајам сљедећа 3 карактера(слова) и добијемо на
излазу ric .
Подстрингови
Примјер5: Испис слова од неке позиције p до k-број слова бројећи
од p.

More Related Content

Featured

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 

Featured (20)

How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 

STRINGOVI

  • 1. СТРИНГОВИ У програмском језику C++ постоји тип података string који садржи текст. За рад с низом знакова може се користити тип string или char. Тип string се користи у случају када се ради с ријечима или реченицама, док тип char само када се ради са једним знаком (а ту врсту промјењиве ћемо користити у 9. разреду кад будете научили низове-поља и цикличне алгоритамске структуре, наредбу for). При раду с типом string на почетку програма потребно је извршити декларацију промјењиве наредбом: string ime_promjenjive; За учитавање стринга до размака(једна ријеч) користи се наредба cin а за исписивање стринга на екран користи се cout наредба из датотеке iostream.
  • 2. Примјер1: Напишите програм ”IME” који исписује унесени текст. УЛАЗ ИЗЛАЗ
  • 3. Примјер2: Напишите програм ”IME I PREZIME” који исписује унесени текст. "Спајање" два стринга Два стринга(ријечи), или више њих се могу спојити користећи операцију сабирања "+" као што смо радили сабирајући бројеве. УЛАЗ ИЗЛАЗ ОБРАДА
  • 4. Уколико желимо да унесемо цијелу линију текста - реченицу морамо користити функцију getline(cin, ime_varijable); Примјер3: Напишите програм који исписује унесени текст.
  • 5. Дужина стринга Слова, размаци, знаци интерпункције и сви остали знаци који се користе у рачунару називају се карактери. Да бисмо добили број карактера у неком стрингу користимо функцију length () или size(). Примјер4: Напиши програм који исписује дужину унесеног текста.
  • 6. Можемо издвојити дио стринга функцијом substr. Ова функција не уклања подстринг из оригиналног стринга; умјесто тога, она креира нови стринг који садржи одређени подстринг датог оригиналног стринга (издваја дио ријечи или реченице). Тражени подстринг је одређен почетном позицијом и бројем карактера тј. дужином, узимајући у обзир да је позиција почетног карактера стринга 0. Примјер: Marica Од позије 2 издвајам сљедећа 3 карактера(слова) и добијемо на излазу ric . Подстрингови
  • 7. Примјер5: Испис слова од неке позиције p до k-број слова бројећи од p.