• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

It is, but I think I like Python's white space deliminator than do/end. The "ends" make the code a little less friendly to read.

Also, the way lamdas/procs work make them less neat than I would prefer.

Other than that, it's noice.

I think I'd prefer python to have an "end" just for functions only or if it could be eliminated from ruby loops and if statements but kept for functions. makes it slightly easier to see where shit ends sometimes.
 

Chairman85

Member
guys i have question about splitting a string in java.

User enters a string in java, I have to split it into different components.


Code:
Scanner scanner = new Scanner(System.in);
      String test = scanner.next();
       
       
       // split the test variable using the split method
        String [] parts = test.split(" ,", 3);
        
        s[i].setFirstName(parts[0].trim());
        s[i].setlastName(parts[1].trim());
        s[i].setID(Integer.parseInt(parts[2].trim()));
        s[i].setgrade(Integer.parseInt(parts[3].trim()));

but its not working! I tried various test programs but i can only get the first word to show up. Please help

A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. So if your expected input looks like
Code:
Joe, Smith, 23, 12
scanner.next() will return "Joe,".
 

NotBacon

Member
...and much more code in library...

Now, can we even determine composition/aggregation from that?

I always thought:

- Composition: class has an object as a data member.
- Aggregation: class has a pointer to an object as a data member, and manages the lifetime of it.
- Association: class has a pointer to an object as a data member, doesn't manage lifetime.

So it seems like you're doing aggregation.
 
So I ran into a weird situation where my C function - basically meant to check whether a 2d array was sorted or not - should have been checking to see whether the array went 1,2,3 etc and counting up to a limit. Once that limit was hit, it would return true.

The issue I had was that there is a zero in the array and the program would count the "0" as being equivalent to whatever it was being compared to (typically "7" due to how I was testing it). I ultimately fixed it by adding an "else if" clause just for the 0 case. What is the reasoning for this? Or was something else causing it? I know it might be hard to answer given a single function from a small game but it was bothering me all day.

Code:
bool won(void)
{
    int limit = d*d-1;
    int test = 1;
    int counter = 0;
    for(int i = 0; i < d; i++){
        for(int j = 0; j < d; j++){
            if(board[i][j] == test){
                counter++;
                test++;
            } else if (board[i][j] == 0){
                test++;
            }
            else{
                counter--;
            }
        }
    }
    if(counter == num) {
        return true;
    } else {
        counter = 0;
        test = 1;
        return false;
    }
}
 
So I ran into a weird situation where my C function - basically meant to check whether a 2d array was sorted or not - should have been checking to see whether the array went 1,2,3 etc and counting up to a limit. Once that limit was hit, it would return true.

The issue I had was that there is a zero in the array and the program would count the "0" as being equivalent to whatever it was being compared to (typically "7" due to how I was testing it). I ultimately fixed it by adding an "else if" clause just for the 0 case. What is the reasoning for this? Or was something else causing it? I know it might be hard to answer given a single function from a small game but it was bothering me all day.

Code:
bool won(void)
{
    int limit = d*d-1;
    int test = 1;
    int counter = 0;
    for(int i = 0; i < d; i++){
        for(int j = 0; j < d; j++){
            if(board[i][j] == test){
                counter++;
                test++;
            } else if (board[i][j] == 0){
                test++;
            }
            else{
                counter--;
            }
        }
    }
    if(counter == num) {
        return true;
    } else {
        counter = 0;
        test = 1;
        return false;
    }
}

It's kind of hard to understand this code, but that said this is kind of a weird algorithm. If all you want to do is check if the array is sorted, the easiest way to do that is to scan through front to back, and return false as soon as you find one item that is out of place.

Code:
bool won(void) {
    int previous = 0;
    for(int i = 0; i < d; i++){
        for(int j = 0; j < d; j++){
            if ((i != 0 || j != 0) && board[i][j] <= previous)
                return false;
            previous = board[i][j];
        }
    }
    return true;
}
 
Anyone work with VMs much in here? I'm running Ubuntu through Virtualbox on my Dell XPS 13 2015 (i5 and 8 GB) and it's incredibly slow. I like writing C most in that environment but it's such a hassle to use at times. I also have weird issues like where I'll tap a key once and it will continually type until I tap another key. I do have 3D acceleration enabled but it's not perfect.

Is this just the nature of VMs (or maybe just Virtualbox)? I suppose my laptop could also just be too slow and I'd have a better experience on my desktop.
 

Kalnos

Banned
Anyone work with VMs much in here? I'm running Ubuntu through Virtualbox on my Dell XPS 13 2015 (i5 and 8 GB) and it's incredibly slow. I like writing C most in that environment but it's such a hassle to use at times. I also have weird issues like where I'll tap a key once and it will continually type until I tap another key. I do have 3D acceleration enabled but it's not perfect.

Is this just the nature of VMs (or maybe just Virtualbox)? I suppose my laptop could also just be too slow and I'd have a better experience on my desktop.

I use VirtualBox and Mint and it's pretty flawless. 8GB of ram towards the VM of 16GB on the host machine in my case.
 

hateradio

The Most Dangerous Yes Man
I like writing C most in that environment
By this, do you mean Ubuntu or Linux in general?

If the latter, there are probably a few lighter environments that you can use.

If you just need a compiler, you can use Docker to boot up a VM for you that you will only use to compile. It won't have desktop environment or anything.
 
I use VirtualBox and Mint and it's pretty flawless. 8GB of ram towards the VM of 16GB on the host machine in my case.

I could try upping the RAM. I think I have it at 3 GB.

By this, do you mean Ubuntu or Linux in general?

If the latter, there are probably a few lighter environments that you can use.

If you just need a compiler, you can use Docker to boot up a VM for you that you will only use to compile. It won't have desktop environment or anything.

Sorry, I meant just using Ubuntu.

I could use whatever I wanted for my OS class last semester and simply decided to go with that since it seemed friendly for someone with little Linux experience. I could probably try something lighter if that's the best way to go in my situation.
 

NotBacon

Member
Anyone work with VMs much in here? I'm running Ubuntu through Virtualbox on my Dell XPS 13 2015 (i5 and 8 GB) and it's incredibly slow. I like writing C most in that environment but it's such a hassle to use at times. I also have weird issues like where I'll tap a key once and it will continually type until I tap another key. I do have 3D acceleration enabled but it's not perfect.

Is this just the nature of VMs (or maybe just Virtualbox)? I suppose my laptop could also just be too slow and I'd have a better experience on my desktop.

Are you running the latest BIOS? The 2015 XPS line had some keyboard issues iirc, that were fixed in a BIOS update.
 
Anyone work with VMs much in here? I'm running Ubuntu through Virtualbox on my Dell XPS 13 2015 (i5 and 8 GB) and it's incredibly slow. I like writing C most in that environment but it's such a hassle to use at times. I also have weird issues like where I'll tap a key once and it will continually type until I tap another key. I do have 3D acceleration enabled but it's not perfect.

Is this just the nature of VMs (or maybe just Virtualbox)? I suppose my laptop could also just be too slow and I'd have a better experience on my desktop.

Repeating keys sounds a bit like you don't have the VM tools installed. I know VMWare throws a fit if you don't have its tools installed on the OS; I'm pretty sure VirtualBox has extra tools as well although you have to find them online.
 
Repeating keys sounds a bit like you don't have the VM tools installed. I know VMWare throws a fit if you don't have its tools installed on the OS; I'm pretty sure VirtualBox has extra tools as well although you have to find them online.

Yep, VirtualBox has additional tools that can be installed in the guest OS to optimize performance and stability:

https://www.virtualbox.org/manual/ch04.html

Also, make sure Intel Virtualization Technology (VT-X) is enabled in your BIOS. It'll also to be good to do a BIOS upgrade, as NotBacon mentioned.
 
I'm having some real trouble wrapping my head around this.

How would I create a dynamic array that itself contains dynamic arrays that contain pointers to Class objects?

Object ** array = new Object* [size of the array]

This would create a dynamic array of pointers to Object items, right?

Then, how do I fill a second dynamic array with these 1D dynamic arrays?
 
I'm having some real trouble wrapping my head around this.

How would I create a dynamic array that itself contains dynamic arrays that contain pointers to Class objects?

Object ** array = new Object* [size of the array]

This would create a dynamic array of pointers to Object items, right?

Then, how do I fill a second dynamic array with these 1D dynamic arrays?
You have an Object* and want to make an array out of it. So you just make a pointer to the pointer: (Object*)*, or Object**. That's where you are. Now you just need to perform that step an additional time. You want to make an array out of those Object**, so you just make a pointer to it: (Object**)*, or Object***.

Code:
Object*** array = new Object**[size]
will create a dynamic array containing a dynamic arrays containing Object-pointers.

Though just like when you create an array of pointers to Object, the objects won't have actually been created. You have to loop through the array and create the objects that you're pointing to. Similarly, you'll have to loop through that array to create the arrays containing the pointers.

Code:
for (int i=0; i<size; i++) {
    array[i] = new Object*[size];
}
 
I'm having some real trouble wrapping my head around this.

How would I create a dynamic array that itself contains dynamic arrays that contain pointers to Class objects?

Object ** array = new Object* [size of the array]

This would create a dynamic array of pointers to Object items, right?

Then, how do I fill a second dynamic array with these 1D dynamic arrays?

Code:
std::vector<std::vector<Object*>> two_d_array;
 
Code:
std::vector<std::vector<Object*>> two_d_array;

If I'm being honest, it is for a class assignment.

Though the instructor never bothered covering 2D or dynamic arrays so...

We got clarification that we can use a dynamic array of dynamic arrays instead of a dynamic 2D array. But then it makes no sense to me why a vector couldn't be used.

You have an Object* and want to make an array out of it. So you just make a pointer to the pointer: (Object*)*, or Object**. That's where you are. Now you just need to perform that step an additional time. You want to make an array out of those Object**, so you just make a pointer to it: (Object**)*, or Object***.

Code:
Object*** array = new Object**[size]
will create a dynamic array containing a dynamic arrays containing Object-pointers.

Then you'll have to loop through that array to create the arrays containing the pointers.

Code:
for (int i=0; i<size; i++) {
    array[i] = new Object*[size];
}

Thanks a bunch.
 
To clarify, a real dynamic 2D array would be one contiguous block of memory right?

But an array of arrays will not. Nor would a vector of vectors. Correct?

Actually though, if that is correct, why does it even matter?
 
To clarify, a real dynamic 2D array would be one contiguous block of memory right?

But an array of arrays will not. Nor would a vector of vectors. Correct?

Actually though, if that is correct, why does it even matter?

At this point it's just terminology. A "dynamic 2d array" is different depending on who you ask. The main difference between a contiguous block of memory and array of arrays is that an array fo arrays can be jagged but a contiguous block of memory will be rectangular. E.g this is not possible with a contiguous block of memory:

Code:
1 2 3
4 5 6 7 8
9
10 11 12

it would have to look like this:

Code:
1 2 3
4 5 6
7 8 9
 

upandaway

Member
At this point it's just terminology. A "dynamic 2d array" is different depending on who you ask. The main difference between a contiguous block of memory and array of arrays is that an array fo arrays can be jagged but a contiguous block of memory will be rectangular. E.g this is not possible with a contiguous block of memory:

Code:
1 2 3
4 5 6 7 8
9
10 11 12

it would have to look like this:

Code:
1 2 3
4 5 6
7 8 9
I'm only keeping this in mind because I've got a computer structure test on friday, but another difference between the jagged array and nested array is how the compiler calculates each cell's address. So in the jagged array you'd have to access the memory twice for a random cell, but for a nested array you only have to access it once => something like A[4][-1] = 12 is illegal for your jagged array but A[3][-1] = 9 works for the nested one.
 
I'm only keeping this in mind because I've got a computer structure test on friday, but another difference between the jagged array and nested array is how the compiler calculates each cell's address. So in the jagged array you'd have to access the memory twice for a random cell, but for a nested array you only have to access it once => something like A[4][-1] = 12 is illegal for your jagged array but A[3][-1] = 9 works for the nested one.

True, but if the contiguous block of memory is *actually* dynamic (in the sense that you allocated it with the new keyword), then A[x][y] syntax doesn't even work anyway. How would the compiler know the dimensions? So in that case you have to manually index it.

*(A + width*y + x)
A[width*y + x]

would both work. In the jagged array A[x][y] is always a legal syntax because A[x] simply returns a new array, and A[x][y] indexes y places into the array returned by A[x].

That said, you are correct that the first one requires 1 memory access and the second requires 2. (This makes the first substantially faster than the second)
 

upandaway

Member
I can't check myself right now but I meant like

Code:
int foo(int A[][3], int size) {
    return A[size-1][2]; // compiler will change to A[(size-1)*3 + 2]
}

Where A is a nested array
 

Anarion07

Member
I'm not quite sure where to ask this, but I'm developing an iOS App at the moment and we're getting closer to launch.
I'd love to get some people to test my app via TestFlight, is there some thread for that? Or can I make a new one for it? (Guess not because of self-marketing stuff)
 
Not sure if many of you have ran into this situation, but when running code on Visual Studio, I am unable to input information in the command prompt. Am I missing an important piece of code? The same exact material runs fine on another computer.
 
I can't check myself right now but I meant like

Code:
int foo(int A[][3], int size) {
    return A[size-1][2]; // compiler will change to A[(size-1)*3 + 2]
}

Where A is a nested array

Ahh but that wouldn't be "dynamic". If you want it to be dynamic the new keyword has to be involved somehow. Otherwise it's static. But yea you can certainly declare a 2d static array
 
Not sure if many of you have ran into this situation, but when running code on Visual Studio, I am unable to input information in the command prompt. Am I missing an important piece of code? The same exact material runs fine on another computer.

Will need more to go on than this. Like how you're creating the project and compiling, how you're running, what your code looks like, and exactly what you mean by unable to input information
 

Mr.Mike

Member
Does anyone have any interview questions about databases or object-oriented programming (in general, no specific language) ? Or maybe a link to somewhere I can find them.

Tomorrow I have an interview with Statistics Canada, and I understand that these are the sorts of questions they usually ask. I also have interviews with a local company for two positions (Systems Administrator and Services Administrator), so maybe some of the sorts of questions they'd ask would be cool.
 
Does anyone have any interview questions about databases or object-oriented programming (in general, no specific language) ? Or maybe a link to somewhere I can find them.

Tomorrow I have an interview with Statistics Canada, and I understand that these are the sorts of questions they usually ask. I also have interviews with a local company for two positions (Systems Administrator and Services Administrator), so maybe some of the sorts of questions they'd ask would be cool.

I dunno about databases, but being able to explain inheritance vs composition, polymorphism, etc are things I've been asked by companies in the past.
 
Will need more to go on than this. Like how you're creating the project and compiling, how you're running, what your code looks like, and exactly what you mean by unable to input information
I'm running a simple line of code that lets the user input two integers, and the result will give you the multiplication of the numbers. When running the line of code, it doesn't let me input any integers on the console. I'm utilizing scanf_s, but I'm unable to input anything.
 
I'm running a simple line of code that lets the user input two integers, and the result will give you the multiplication of the numbers. When running the line of code, it doesn't let me input any integers on the console. I'm utilizing scanf_s, but I'm unable to input anything.

I gathered that much from your original post, but this still doesn't tell me anything.
Does a console window pop up?
Do you see any output from printf statements?
What if you use std::cin instead of scanf?
Did you create a Visual Studio project? If so what settings did you use going through the initial wizard?

Maybe you can post a screenshot of the IDE with the console in the foreground and your code in the background.
 
It's kind of hard to understand this code, but that said this is kind of a weird algorithm. If all you want to do is check if the array is sorted, the easiest way to do that is to scan through front to back, and return false as soon as you find one item that is out of place.

Code:
bool won(void) {
    int previous = 0;
    for(int i = 0; i < d; i++){
        for(int j = 0; j < d; j++){
            if ((i != 0 || j != 0) && board[i][j] <= previous)
                return false;
            previous = board[i][j];
        }
    }
    return true;
}

That is much more concise than mine (in my defense I beat my head against this particular function for a long time and concision was the last thing on my mind). The only issue - not that I ever mentioned exactly what my code did so you couldn't have known - is that the final element of the final array is always going to be 0. Is there an easy way to check that?
 
That is much more concise than mine (in my defense I beat my head against this particular function for a long time and concision was the last thing on my mind). The only issue - not that I ever mentioned exactly what my code did so you couldn't have known - is that the final element of the final array is always going to be 0. Is there an easy way to check that?

You said the final element of the final array. Aren't we're only really talking about 1 array here right -- board -- which is one 2-dimensional array? Do you just mean the final element of this array has to be 0? Is it actually important to check that? I mean if you have this:

Code:
1 2 3
4 5 6
7 8 9

Is that a losing board, while this:

Code:
1 2 3
4 5 6
7 8 0

is a winning board?

Or do you just mean that you need to make sure not to return false on the last iteration of the nested loop, since the last item will always be 0? Either way, it sounds like you just need to add an extra condition to the place where you return false that checks whether you're on the last element of the array.
 

Two Words

Member
I am having trouble understanding this C code for my UNIX class. I was given this code and I have to explain how it works. The single line "//'' comments are what I wrote. The "/*...*/ quotes are from the professor. I understand that it is recursively printing each directory and the files within the directory, but there are a lot of functions used that I don't understand. For example, I don't get how a DIR pointer can be assigned to adirent structure pointer. I've tried to read up on a lot of these functions, but I feel like I don't understand what a lot of these functions do or the data structures they operate on. I'm not sure if there is a concise way to explain what is happening that doesn't require me to understand fully what is happening behind the scene, which our professor does not expect us to know.

Code:
/* printdir1.c
 * Documentation intentionally left out as part of the assignment
 */


#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>

void printdir(char *dir, int depth)
{

   DIR *dp;               // A pointer to a directory stream
   struct dirent *entry;  // A struct, directory entries
   struct stat statbuf;   //A struct of stats on a file

   // Open a directory, and if it is NULL, the directory cannot be opened and return
   if((dp = opendir(dir)) == NULL) {
      fprintf(stderr,"cannot open directory: %s\n", dir);
         return;
   }

   chdir(dir); // Change the current working directory to dir

   //
   while((entry = (dp)) != NULL) {
      lstat(entry->d_nareaddirme,&statbuf);

      if(S_ISDIR(statbuf.st_mode)) {
          /* Found a directory, but ignore . and .. */
          if(strcmp(".",entry->d_name) == 0 || 
                strcmp("..",entry->d_name) == 0) {
             continue;
	  }

          printf("%*s%s/\n",depth,"",entry->d_name);

          /* Recurse at a new indent level */
          printdir(entry->d_name,depth+4);
      }
      else {
         printf("%*s%s\n",depth,"",entry->d_name);
      }
   }
   chdir("..");
   closedir(dp);
}

/*  Now we move onto the main function.  */

int main()
{
   printf("Directory scan of /home:\n");
   printdir("./",0);   // print current directory entries
   printf("done.\n");

   exit(0);
}
 
You said the final element of the final array. Aren't we're only really talking about 1 array here right -- board -- which is one 2-dimensional array? Do you just mean the final element of this array has to be 0? Is it actually important to check that? I mean if you have this:

Code:
1 2 3
4 5 6
7 8 9

Is that a losing board, while this:

Code:
1 2 3
4 5 6
7 8 0

is a winning board?

Or do you just mean that you need to make sure not to return false on the last iteration of the nested loop, since the last item will always be 0? Either way, it sounds like you just need to add an extra condition to the place where you return false that checks whether you're on the last element of the array.

Sorry, I tend to think of a 2D array as an array of multiple arrays since it makes more sense to me that way. I suppose it's not technically accurate. The entire program is actually just a 15 puzzle (in this case a 9 through 100 puzzle based on what the user inputs) so

Code:
1 2 3
4 5 6
7 8 0

would be the winning board. Anyways, just adding a condition is simple enough. It's 3AM here so I'm probably making less sense than I should be.
 

Koren

Member
That is much more concise than mine (in my defense I beat my head against this particular function for a long time and concision was the last thing on my mind). The only issue - not that I ever mentioned exactly what my code did so you couldn't have known - is that the final element of the final array is always going to be 0. Is there an easy way to check that?

If you know the numbers are integers between 0 and N-1, you can use the last cell as initialization value...
Code:
bool won(void) {
    int previous = board[d-1][d-1];
    for(int i = 0; i < (d*d-1); i++){
            if (board[i/d][i%d] <= previous)
                return false;
            previous = board[i][j];
    }
    return true;

Or you can also do a full check:
Code:
bool won(void) {
    for(int i = 0; i < (d*d); i++)
            if (board[i/d][i%d] != (i+1)%(d*d))
                return false;
    return true;
(with a single loop or a double loop)
 
I gathered that much from your original post, but this still doesn't tell me anything.
Does a console window pop up?
Do you see any output from printf statements?
What if you use std::cin instead of scanf?
Did you create a Visual Studio project? If so what settings did you use going through the initial wizard?

Maybe you can post a screenshot of the IDE with the console in the foreground and your code in the background.
A console window pops up. I'm unable to type in 2 different numbers on it. The printf statements are supposed to output the result. I tried using std::cin, but it's not working properly with the code.

As far as creating a project, I've done it through Visual Studio. I chose Win32 Console Application.
 
A console window pops up. I'm unable to type in 2 different numbers on it. The printf statements are supposed to output the result. I tried using std::cin, but it's not working properly with the code.

As far as creating a project, I've done it through Visual Studio. I chose Win32 Console Application.

I still haven't seen the actual code, so I'm not sure what else to suggest.
 

Haly

One day I realized that sadness is just another word for not enough coffee.
So you're not able to type into the console at all?

I just tried it and it worked fine, weather I split the numbers on different lines or left them on a single line, as long as there was some whitespace.
 
So you're not able to type into the console at all?

I just tried it and it worked fine, weather I split the numbers on different lines or left them on a single line, as long as there was some whitespace.
I'm unable to type into the console at all. Could it be a problem with Windows 10? I'm using the Community version of Visual Studios.
 
I'm unable to type into the console at all. Could it be a problem with Windows 10? I'm using the Community version of Visual Studios.

I still can't see the code (looks like you removed it?). But someone else said it worked, so it's not that. Try running the program by hitting Ctrl+F5 inside of visual studio. Can you type into it?
 

Haly

One day I realized that sadness is just another word for not enough coffee.
I still can't see the code (looks like you removed it?). But someone else said it worked, so it's not that. Try running the program by hitting Ctrl+F5 inside of visual studio. Can you type into it?

It's hidden behind email tags so you need to click quote to see the contents.

I think a computer restart or a full reinstall might be in order.
 
It's hidden behind email tags so you need to click quote to see the contents.

I think a computer restart or a full reinstall might be in order.

I did, but when I quote it still says removed. I have an idea what might be wrong, but I want to see what happens when he pushes Ctrl+F5 first.
 
CTRL + F5 runs and opens CMD, but I'm still unable to input the numbers. Gonna try reinstalling it.

Ok in that case my idea about what was wrong wasn't correct. Re-installing it doesn't make sense (as in i don't see how that could possibly fix it), I would try compiling it from the command line and running it from the command line and seeing if that works.
 
I know that Python needs it (for whatever reason), but the syntax for classes is just so unintuitive and dumb.

__init__ stuff, and having to pass self. Like... why?
 
Ok in that case my idea about what was wrong wasn't correct. Re-installing it doesn't make sense (as in i don't see how that could possibly fix it), I would try compiling it from the command line and running it from the command line and seeing if that works.
When running it through the command line, it opens up Visual Studios. Could this be a Windows 10 issue?

Edit: Tried to ouput text, and that isn't working either.
 
When running it through the command line, it opens up Visual Studios. Could this be a Windows 10 issue?

Edit: Tried to ouput text, and that isn't working either.

No, it's more likely an issue of you doing something wrong. Running your program from the command line and it launching visual studio tells me that we're probably having a communication breakdown. Because that really makes no sense whatsoever. I think I'm saying one thing, and you're interpreting it as something else.

Try following these steps.

1. Open Visual Studio
2. Click File -> New -> Project
3. Choose Templates -> Visual C++ -> Win32 Console Application
4. Press Ok
5. Click Finish. You will be looking at a file like this:

Code:
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int main()
{
    return 0;
}

6. Delete everything and paste this in:

Code:
#include "stdafx.h"
#include <stdio.h>

int main()
{
    int n;
    printf("Enter a number: ");
    scanf_s("%d", &n);
    return 0;
}


7. Press Ctrl+Shift+B
8. Press F5

This should work. And if it does, it means you are doing something wrong / differently in your steps.

I can't see your screen or your code, or tell what buttons you're pressing to build, compile, and run, so all I can tell is that something is happening that is impossible.
 
Top Bottom