CString技法
abcdefghijklmnopqrstuvwxyz
字串搜尋
最後更新日期:2013年5月7日
Outline
• Find()函數
• 找fg左全部
• 找fg左3位
• 取出特定字之間的字
• 找fg右全部
• 找fg右3位
• Find()注意事項
Find()函數找fg
CString sample = “abcdefghijklmnopqrstuvwxyz”;
const CString goal(“fg”);
int goalIndex = sample.Find(goal);
CString::Find()的return
找到: 0~n
找不到: -1
abcdefghijk…
0123456789…
找fg左全部
CString sample = “abcdefghijklmnopqrstuvwxyz”;
const CString goal(“fg”);
int goalIndex = sample.Find(goal);
CString result
= sample.Left(goalIndex);
CString::Find()的return
找到: 0~n
找不到: -1
abcdefghijk…
0123456789…
找fg左3位
CString sample = “abcdefghijklmnopqrstuvwxyz”;
const CString goal(“fg”);
int goalIndex = sample.Find(goal);
const int charAmount = 3;
CString result
= sample.Mid(goalIndex-charAmount, charAmount);
CString::Find()的return
找到: 0~n
找不到: -1
abcdefghijk…
0123456789…
charAmount
取出特定字之間的字
CString sample = “abcdefghijklmnopqrstuvwxyz”;
const CString begin(“bc”), end(“fg”);
int beginIndex = sample.Find(begin);
int endIndex = sample.Find(end);
CString result
= sample.Mid(beginIndex+begin.GetLength(),
endIndex-beginIndex+begin.GetLength());
CString::Find()的return
找到: 0~n
找不到: -1
abcdefghijk…
0123456789…
+begin.GetLength()
找fg右全部
CString sample = “abcdefghijklmnopqrstuvwxyz”;
const CString goal(“fg”);
int goalIndex = sample.Find(goal);
CString result
= sample.Right(sample.GetLength()-
goalIndex+goalIndex.GetLength());
CString::Find()的return
找到: 0~n
找不到: -1
abcdefghijk…
0123456789…
+goalIndex.GetLength()
找fg右3位
CString sample = “abcdefghijklmnopqrstuvwxyz”;
const CString goal(“fg”);
int goalIndex = sample.Find(goal);
const int charAmount = 3;
CString result
= sample.Mid(abcIndex+goalIndex.GetLength(), charAmount);
CString::Find()的return
找到: 0~n
找不到: -1
abcdefghijk…
0123456789…
charAmount
+goalIndex.GetLength()
Find()注意事項
CString sample = “abcdefghijklmnopqrstuvwxyz”;
int errorIndex = sample.Find(“llllll”);
int emptyIndex = sample.Find(“”);
errorIndex: -1
emptyIndex: 0

More Related Content

PPTX
การพัฒนาโปรแกรม เลขที่26
PPTX
การพัฒนาโปรแกรม เลขที่ 26
PPTX
การพัฒนาโปรแกรม วิชญา เลขที่ 26
PDF
JavaScript: enter the dragon
PDF
Demystifying Prototypes
PPTX
Lrz kurse: r as superglue
PPTX
PDF
2. Базовый синтаксис Java
การพัฒนาโปรแกรม เลขที่26
การพัฒนาโปรแกรม เลขที่ 26
การพัฒนาโปรแกรม วิชญา เลขที่ 26
JavaScript: enter the dragon
Demystifying Prototypes
Lrz kurse: r as superglue
2. Базовый синтаксис Java

What's hot (6)

PDF
Implementation of c string functions
PPT
第4章 存储器管理实验
PDF
DeepLearning ハンズオン資料 20161220
DOCX
C program to implement linked list using array abstract data type
DOC
Final ds record
Implementation of c string functions
第4章 存储器管理实验
DeepLearning ハンズオン資料 20161220
C program to implement linked list using array abstract data type
Final ds record
Ad

More from Chris Wang (20)

PDF
屏東縣政府112年度大專青年公部門暑期工讀計畫簡章.pdf
PDF
「設計」在工程師職涯中 扮演的角色
PDF
歡迎加入軟體構築行列
PDF
自我探索的資訊教育
PDF
完美 camp 進化論
PPTX
Dm create message old
PPTX
Dm create message new
PPTX
用 jenkins 實戰 CD/CI
PPTX
MVC Design in Web backend Server
PPT
Bug afx ini-line122
PPT
物件的值莫名奇妙被改掉
PPT
VC6 font setup tips
PPT
MFC tips for single document
PPT
應用於液晶電視中動態背光調光技術之演算法與系統整合實現 論文口試投影片
PDF
偷偷學習 Python3
PDF
思考 Vuex 發送 API 的架構
PDF
從 Flux 認識 vuex
PDF
Information architecture reading ch7
PPTX
用Vue改dom
PPTX
Cppunit下載、編譯、使用與困難排除
屏東縣政府112年度大專青年公部門暑期工讀計畫簡章.pdf
「設計」在工程師職涯中 扮演的角色
歡迎加入軟體構築行列
自我探索的資訊教育
完美 camp 進化論
Dm create message old
Dm create message new
用 jenkins 實戰 CD/CI
MVC Design in Web backend Server
Bug afx ini-line122
物件的值莫名奇妙被改掉
VC6 font setup tips
MFC tips for single document
應用於液晶電視中動態背光調光技術之演算法與系統整合實現 論文口試投影片
偷偷學習 Python3
思考 Vuex 發送 API 的架構
從 Flux 認識 vuex
Information architecture reading ch7
用Vue改dom
Cppunit下載、編譯、使用與困難排除
Ad

Recently uploaded (20)

PPTX
Trending Python Topics for Data Visualization in 2025
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Introduction to Windows Operating System
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PPTX
Computer Software - Technology and Livelihood Education
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
Cybersecurity: Protecting the Digital World
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PDF
Website Design Services for Small Businesses.pdf
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
Time Tracking Features That Teams and Organizations Actually Need
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
Trending Python Topics for Data Visualization in 2025
Monitoring Stack: Grafana, Loki & Promtail
Introduction to Windows Operating System
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Computer Software - Technology and Livelihood Education
Designing Intelligence for the Shop Floor.pdf
Cybersecurity: Protecting the Digital World
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
Website Design Services for Small Businesses.pdf
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Weekly report ppt - harsh dattuprasad patel.pptx
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Time Tracking Features That Teams and Organizations Actually Need
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Autodesk AutoCAD Crack Free Download 2025
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Computer Software and OS of computer science of grade 11.pptx
Wondershare Recoverit Full Crack New Version (Latest 2025)
How to Use SharePoint as an ISO-Compliant Document Management System

CString of MFC skills

  • 2. Outline • Find()函數 • 找fg左全部 • 找fg左3位 • 取出特定字之間的字 • 找fg右全部 • 找fg右3位 • Find()注意事項
  • 3. Find()函數找fg CString sample = “abcdefghijklmnopqrstuvwxyz”; const CString goal(“fg”); int goalIndex = sample.Find(goal); CString::Find()的return 找到: 0~n 找不到: -1 abcdefghijk… 0123456789…
  • 4. 找fg左全部 CString sample = “abcdefghijklmnopqrstuvwxyz”; const CString goal(“fg”); int goalIndex = sample.Find(goal); CString result = sample.Left(goalIndex); CString::Find()的return 找到: 0~n 找不到: -1 abcdefghijk… 0123456789…
  • 5. 找fg左3位 CString sample = “abcdefghijklmnopqrstuvwxyz”; const CString goal(“fg”); int goalIndex = sample.Find(goal); const int charAmount = 3; CString result = sample.Mid(goalIndex-charAmount, charAmount); CString::Find()的return 找到: 0~n 找不到: -1 abcdefghijk… 0123456789… charAmount
  • 6. 取出特定字之間的字 CString sample = “abcdefghijklmnopqrstuvwxyz”; const CString begin(“bc”), end(“fg”); int beginIndex = sample.Find(begin); int endIndex = sample.Find(end); CString result = sample.Mid(beginIndex+begin.GetLength(), endIndex-beginIndex+begin.GetLength()); CString::Find()的return 找到: 0~n 找不到: -1 abcdefghijk… 0123456789… +begin.GetLength()
  • 7. 找fg右全部 CString sample = “abcdefghijklmnopqrstuvwxyz”; const CString goal(“fg”); int goalIndex = sample.Find(goal); CString result = sample.Right(sample.GetLength()- goalIndex+goalIndex.GetLength()); CString::Find()的return 找到: 0~n 找不到: -1 abcdefghijk… 0123456789… +goalIndex.GetLength()
  • 8. 找fg右3位 CString sample = “abcdefghijklmnopqrstuvwxyz”; const CString goal(“fg”); int goalIndex = sample.Find(goal); const int charAmount = 3; CString result = sample.Mid(abcIndex+goalIndex.GetLength(), charAmount); CString::Find()的return 找到: 0~n 找不到: -1 abcdefghijk… 0123456789… charAmount +goalIndex.GetLength()
  • 9. Find()注意事項 CString sample = “abcdefghijklmnopqrstuvwxyz”; int errorIndex = sample.Find(“llllll”); int emptyIndex = sample.Find(“”); errorIndex: -1 emptyIndex: 0