`
wihoho
  • 浏览: 8932 次
  • 性别: Icon_minigender_1
  • 来自: Singapore
最近访客 更多访客>>
社区版块
存档分类
最新评论

Day 4: Arrays and Strings

 
阅读更多

Array

 

  • fixed number of elements of the same type stored sequentially in memory
  • initialization, or unexpected results
  • arrays are passed by reference
  • multidimensional arrays are merely an abstraction for programmers, as all the elements in the array are sequential in memory

 

String

 

  • simply a character array and can be manipulated as such
  • char hello[] = {'h','e','l','l','o','\0',}
  • char hello = "hello"
#include <iostream>
  #include <cstring>
  using namespace std;

  int main() {
  char fragment1[] = "I'm a s";
  char fragment2[] = "tring!";
  char fragment3[20];
  char finalString[20] = "";

  strcpy(fragment3, fragment1);
  strcat(finalString, fragment3);
  strcat(finalString, fragment2);

  cout << finalString;
  return 0;
 }
 

 

0
0
分享到:
评论

相关推荐

    Java Intensive 7 day Course(part3 高级篇)

    Intro, Syntax, Semantics, Arrays, Methods, Strings, Object Orientation 3.5MB JB2 2nd day: Exception Handling, Packages, System Classes, Applets & Applications, How to Continue 2.6MB JI1 3rd day: ...

    PHP.and.MySQL.Recipes.A.Problem-Solution.Approach.1484206061

    Chapter 4: Working with Arrays Chapter 5: Dates and Times Chapter 6: Strings Chapter 7: Files and Directories Chapter 8: Dynamic Imaging Chapter 9: Regular Expressions Chapter 10: Variables Chapter 11...

    Learn.Cplusplus.In.A.DAY.1519318588.epub

    Chapter 4: Operators Chapter 5: Advanced Data Types Chapter 6: Loops and Conditional Statements Chapter 7: Arrays and Pointers Chapter 8: Functions Chapter 9: Operator Overloading Chapter 10: Object ...

    [Teach.Yourself.C.in.One.Hour.a.Day(6th,2008)].Jesse.Liberty.文字版

    4 Managing Arrays and Strings 71 5 Working with Expressions, Statements, and Operators 93 6 Organizing Code with Functions 127 7 Controlling Program Flow 167 8 Pointers Explained 203 9 Exploiting ...

    The C++ Standard Library 2nd Edition(高清)pdf

    You will also find detailed coverage of strings, concurrency, random numbers and distributions, special containers, numerical classes, internationalization, and the IOStreams library. An insightful ...

    C.Programming.Step.By.Step.Beginners.To.Experts.Edition.B011EXMV7Q

    It start right now and by the time you finish and implement the steps here, you will have learned everything there is to know in less than a day! Steps covered to become proficient in C Programming ...

    CLR via C# 第4版 英文PDF

    CHAPTER 14 Chars, Strings, and Working with Text 317 CHAPTER 15 Enumerated Types and Bit Flags 361 CHAPTER 16 Arrays 373 CHAPTER 17 Delegates 391 CHAPTER 18 Custom Attributes 421 CHAPTER 19 Nullable ...

    react-native-push-notification.zip

    - 在`android/app/src/main/res/values/strings.xml`中添加通知渠道ID: ```xml &lt;string name="app_name"&gt;Your App Name &lt;string name="push_notification_channel_id"&gt;your_channel_id ``` - 在`android/app...

    ZendFramework中文文档

    7.13.4. 从 0.6.0 移植到 0.8.0 或更新的版本 7.13.5. 从 0.2.0 或以前的版本移植到 0.6.0 8. Zend_Currency 8.1. Zend_Currency 简介 8.1.1. 为什么使用 Zend_Currency ? 8.2. 如何使用货币 8.2.1. 从货币...

    Day09

    数据类型(data types),如字符串(strings)、数字(numbers)、布尔值(booleans)以及对象(objects)。JavaScript还有特殊的值——null和undefined,它们表示空或未定义的状态。变量在声明时不需要预设类型,这...

    深入理解计算机系统(英文版)

    2.1.5 Representing Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.1.6 Representing Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.1.7...

Global site tag (gtag.js) - Google Analytics