鱼C论坛

 找回密码
 立即注册
查看: 1364|回复: 2

[已解决]事实证明你大爷还是你大爷

[复制链接]
发表于 2019-8-15 23:45:26 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 bin554385863 于 2019-8-15 23:50 编辑
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <cstdio>
  5. int main(int argc, char const *argv[])
  6. {
  7.     using namespace std;
  8.     string str[] = {"hello world", "hello C++"};
  9.     vector<string> svec = {{"fishc"}, {"goodstudy"}};
  10.     string *pstr = str;
  11.     vector<string> *psvec = &svec;
  12.     cout << "pstr---" << pstr << "---" << *pstr << endl;
  13.     cout << "pstr+1---" << pstr + 1 << "---" << *(pstr + 1) << endl;
  14.     cout << "******************************************" << endl;
  15.     cout << "psvec---" << psvec << "---" << svec[0] << endl;
  16.     cout << "psvec+1---" << psvec + 1 << "---" << svec[1] << endl;
  17.     return 0;
  18. }
复制代码

==============================================
Microsoft Windows [版本 10.0.16299.1087]
(c) 2017 Microsoft Corporation。保留所有权利。

E:\Users\86184\Documents\Code>c:\Users\86184\.vscode\extensions\ms-vscode.cpptools-0.24.1\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-25oahm4e.hfu --stdout=Microsoft-MIEngine-Out-tpj5xvcm.ypw --stderr=Microsoft-MIEngine-Error-2g0dpqct.t25 --pid=Microsoft-MIEngine-Pid-1gn25dyk.jcu "--dbgExe=E:\My Program\MinGW\bin\gdb.exe" --interpreter=mi
pstr---0x62fea0---hello world
pstr+1---0x62feb8---hello C++
******************************************
psvec---0x62fe94---fishc
psvec+1---0x62fea0---goodstudy


E:\Users\86184\Documents\Code>

---------------------------------------------------------------------------------------------
如上,指针还是指针,数组还是数组.
并不因为是C++就没落了

就是不知道集合vector类型的数组怎么用指针输出
而且vector并不支持定义数组,大概是应为vector自己就是最方便的数组把
最佳答案
2019-8-15 23:50:32
  1.     vector<string> svec = {{"fishc"}, {"goodstudy"}};
复制代码

一般都是这样输出更方便的
  1. for(const auto &c:svec)
  2. cout<<c<<endl;
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2019-8-15 23:50:32 | 显示全部楼层    本楼为最佳答案   
  1.     vector<string> svec = {{"fishc"}, {"goodstudy"}};
复制代码

一般都是这样输出更方便的
  1. for(const auto &c:svec)
  2. cout<<c<<endl;
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 0 反对 1

使用道具 举报

发表于 2019-8-16 14:39:59 | 显示全部楼层
写的不行
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-26 21:01

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表