# C++ Fundamental types

**URL:** <https://forum.codewithmosh.com/t/c-fundamental-types/14371>\
**Category:** C++\
**Created:** [August 13, 2022, 9:31pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371 "2022-08-13T21:31:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mimeo](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@mimeo](https://forum.codewithmosh.com/u/mimeo)\
**Post date:** [August 13, 2022, 9:31pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/1 "2022-08-13T21:31:57Z")

</div>

Sorry about bad categorization, but there was no C++ category.  
Im following C++ course and it is great.  
However, in Basic course (1st one), under “Fundamental Data Types”, lesson #10 - Working with characters, I keep getting error.  
getline() keeps getting error, regardless if I supply it with 2 parameters or not. Error I keep getting is:  
" Identifier “getline” is undefined".  
I tried searching online for solution, someone mentioned to point VS to where it is - but I have just scratched C++ and I have no idea how to solve it. Copied Mosh`s code to the letter - same issue.  
Help?  
Code in my VS:

```auto
#include <iostream>
using namespace std;

int main()
{
	cout << " What is your street? ";
	string street;
	getline(cin, street);

}

```

---

<div class="post-metadata">

**Author:** ![skyhon](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@skyhon](https://forum.codewithmosh.com/u/skyhon)\
**Post date:** [August 14, 2022, 3:22am UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/2 "2022-08-14T03:22:31Z")

</div>

Nothing wrong with your code. I ran it with CLion, and everything works. For CLion, everything is there, you just press play to run your code, and you don’t need to set your own C++ compiler. I would check your system configuration since it didn’t recognize the getline function.

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [August 14, 2022, 3:26am UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/3 "2022-08-14T03:26:10Z")

</div>

Are you using VSCode? If so, perhaps try following this canonical guide:

> **[C++ programming with Visual Studio Code](https://code.visualstudio.com/docs/languages/cpp)**
>
> Find out how to get the best out of Visual Studio Code and C++.

---

<div class="post-metadata">

**Author:** ![mimeo](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@mimeo](https://forum.codewithmosh.com/u/mimeo)\
**Post date:** [August 14, 2022, 7:33pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/4 "2022-08-14T19:33:55Z")

</div>

No mate. I use VS Code for Python and others, for C++ I am using Microsoft Visual Studio Community Edition x64 ( as per suggestion from Mosh`s video), v17.3.0 from 2022.  
Complete data:

```auto
Microsoft Visual Studio Community 2022
Version 17.3.0
VisualStudio.17.Release/17.3.0+32804.467
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

Visual C++ 2022 00482-90000-00000-AA154
Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.3.375.53775
ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.3.375.53775
Azure App Service Tools v3.0.0

C# Tools 4.3.0-3.22401.3+41ae77386c335929113f61d6f51f2663d2780443
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

NuGet Package Manager 6.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools 17.0.10701.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.3.0-3.22401.3+41ae77386c335929113f61d6f51f2663d2780443
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

```

---

<div class="post-metadata">

**Author:** ![jmrunkle](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/jmrunkle/32/3765_2.png) [@jmrunkle](https://forum.codewithmosh.com/u/jmrunkle)\
**Post date:** [August 14, 2022, 7:46pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/5 "2022-08-14T19:46:49Z")

</div>

Per [documentation for `std::getline`](https://en.cppreference.com/w/cpp/string/basic_string/getline), it looks like it may be defined in the `string` package, so try including that in your imports:

```nohighlight
#include <string>
#include <iostream>

```

---

<div class="post-metadata">

**Author:** ![mimeo](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@mimeo](https://forum.codewithmosh.com/u/mimeo)\
**Post date:** [August 14, 2022, 8:07pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/6 "2022-08-14T20:07:39Z")

</div>

This solved it. Thank you very much!

---

<div class="post-metadata">

**Author:** ![mimeo](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@mimeo](https://forum.codewithmosh.com/u/mimeo)\
**Post date:** [August 17, 2022, 8:36pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/7 "2022-08-17T20:36:14Z")

</div>

Me again.  
Again in first C== course, section “For loops” - lesson “Range based for loops” been following Mosh`s instructions and typed same as he did. However my code runs 12 times, instead of 3, like in CLion does. Could it be due to MS VS IDE?  
Code:

```auto
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int numbers[] = { 1, 2, 3 };
	for (int i = 0; i < sizeof(numbers); i++)
		cout << numbers[i] << endl;
	cout << sizeof(numbers);

	return 0;
	

}

```

Output I get:

```auto
1
2
3
-858993460
-858993460
-858993460
-858993460
-858993460
-858993460
-858993460
-858993460
11
12

```

I know addresses from index 3 to 10 contain garbage. But what is value 11?!  
For output 12 I know its cout call of sizeof() function, but why am I getting this strange data?  
And does in fact in my IDE C++ iterates over every single byte, rather than int value (3x4 bytes = 12).  
Very confusing for a newbie like myself… ☹

---

<div class="post-metadata">

**Author:** ![mimeo](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@mimeo](https://forum.codewithmosh.com/u/mimeo)\
**Post date:** [August 17, 2022, 8:40pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/8 "2022-08-17T20:40:36Z")

</div>

Small update: my VS iterates over every byte, producing wrong output. 😃  
Tried adding 4th number to array - iterated 16 times.  
Changed data type to short - iterated 8 times…  
How to solve this?

---

<div class="post-metadata">

**Author:** ![mimeo](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@mimeo](https://forum.codewithmosh.com/u/mimeo)\
**Post date:** [August 17, 2022, 8:41pm UTC](https://forum.codewithmosh.com/t/c-fundamental-types/14371/9 "2022-08-17T20:41:53Z")

</div>

Disregard all, Mosh explained, I was too quick to type. Sorry.
