Lasthope106
Member
Yeah, why not?
My interview went well... I think?
If you think it went well, you probably have the job. I come out of most interviews feeling like I'm humanity's biggest failure.
Yeah, why not?
My interview went well... I think?
Are there any good programming podcasts out there? Thinking about loading up my phone with some when I go to take a walk.
Can someone explain how pointers work? Reading it in my C++ book, it seems like I'm being thrown a bunch of concepts and explanations with no real write up of how or why pointers are important
Check out this guy named Bucky's C++ Youtube videos. They're pretty awesome in terms of breaking down the concepts into easy to relate to examples and actually showing you some code on screen of what he is talking about. I was struggling with a lot of stuff but seeing the code being written, built and executed in real-time on a screen helped immensely versus trying to decipher how it all fits together from static print on a textbook page.Can someone explain how pointers work? Reading it in my C++ book, it seems like I'm being thrown a bunch of concepts and explanations with no real write up of how or why pointers are important
You need pointers to mess with raw memory. That is mainly necessary in situations where you want to write your own data structures from the ground up. Otherwise, good modern C++ code should use pointers only rarely.Can someone explain how pointers work? Reading it in my C++ book, it seems like I'm being thrown a bunch of concepts and explanations with no real write up of how or why pointers are important
....I just realized how little I use pointers in C++. Every project has at least one or two but I use a lot less than I do in C.You need pointers to mess with raw memory. That is mainly necessary in situations where you want to write your own data structures from the ground up. Otherwise, good modern C++ code should use pointers only rarely.
With what exactly do you have trouble with?
Pointers are not that hard to grasp as they seem at first.
Pointers point to a location in memory.
if you do char *p=0x01234. It points to the memory location 0x01234. You can then read the value that is stored at 0x0123 like so: printf("Value at 0x1234 is %c", *p).
Notice the (*), this is used to access the value of said memory location.
Since pointers store the memory location you can also retrieve that by simply doing
printf("Value at %p is %c", p, *p);
Again notice the (*), with the asterisk you access the value, without the memory location.
If you do:
*p = 10//set value that the pointer points to, to 10
p = 10//set the pointer to point to memory adress 10
Also note that char *p = 10 and *p = 10 is NOT the same.
The first statement declares a char pointer that points to memory location 10.
Second statement is a simple assignment.
That can be confusing at first, since the use of the asterisk is different.
You also don't need to explicitly point to memory location by hand.
Say you want to point to a known variable:
int i=23;
int *p = null;
p = &i; //get the address of i via the & operator
*p = 58; //same as i=58 since p "points" to it
When you allocate memory dynamically with new/malloc you also get a pointer back in return.
I mean there's more to pointers like function pointers but the above is the basic concept behind it.
You can't get anything done in C without pointers. For example, C doesn't have a separate datatype for strings; C strings are pointers to an array of characters. (If you think that sounds like a mess, you are absolutely correct.)It starts getting complicated when combined with references, classes, constructors, destructors, and the like. So it's not that important in the grand scheme of things? just based on how much stuff im being thrown here I thought it was a very important part of writing code in C++
I'm gonna be doing a class in C starting Tuesday, how important are pointers in C?
Otherwise, good modern C++ code should use pointers only rarely.
round date team_1 team_2 score_1 score_2
1 2013-08-17 John Brian 5 5
1 2013-08-17 Jack Bird 5 5
1 2013-08-17 Josh Bean 5 5
2 2013-08-24 Brian John 5 5
2 2013-08-24 Bird Jack 5 5
2 2013-08-24 Bean Josh 5 5
$games = array(
array(
'round' => 1,
'date' => '2013-08-17',
'team_1' => 'John',
'team_2' => 'Brian',
'score_1' => 5,
'score_2' => 5,
),
array(
'round' => 1,
'date' => '2013-08-17',
'team_1' => 'Jack',
'team_2' => 'Bird',
'score_1' => 5,
'score_2' => 5,
),
);
2013-08-17
Round 1
John 5 - 5 Brian
Jack 5 - 5 Bird
Josh 5 - 5 Bean
2013-08-24
Round 2
Brian 5 - 5 John
Bird 5 - 5 Jack
Bean 5 - 5 Josh
In your own words, how would you convert roman numbers to decimal? Which steps would you need?
In your own words, how would you convert roman numbers to decimal? Which steps would you need?
Just store the date, if everything is stored by date and round.SQL + PHP question.
I have filled an array with a result set of a large amount of games. What is a simple way to output the array by grouping some of the values?
The way I get the wanted ouput can not be the most simple way (building multidimensional raids from two queries).
SQL result set
Code:round date team_1 team_2 score_1 score_2 1 2013-08-17 John Brian 5 5 1 2013-08-17 Jack Bird 5 5 1 2013-08-17 Josh Bean 5 5 2 2013-08-24 Brian John 5 5 2 2013-08-24 Bird Jack 5 5 2 2013-08-24 Bean Josh 5 5
$date = '';
foreach($games as $g) {
// Output the date/round once
if ($date != $g['date']) {
echo $g['date'] . "\nRound " . $g['round'] . "\n";
}
// store the date
$date = $g['date'];
printf("%s %d - %d %s\n", $g['team_1'], $g['score_1'], $g['score_2'], $g['team_2']);
}
Just stick with it if you have an interest. Many people will tell you to quit if you don't LOOOOOOOOOOOVE programming right away, but I don't think this is good advice for everyone. My first year of school I pretty much hated programming and hated my life, but once i started to understand how things were working together and being able to creatively accomplish non-trivial engineering problems, I really started to love it. C++ is hard to start out with. Just keep plugging away and don't stress out about things like "another semester". Take the time to learn it thoroughly and you'll be much better off in the end.
Yeah, my previous comment shouldn't be taken as an absolute. There are times and places where you need a pointer in C++, or another way would be too contrived. What I was getting at is that beginners should be suspicious of pointers and shouldn't touch them until they have a real reason. Especially people who have previously done some C programming have a tendency to write atrocious C++. Having them stop using pointers entirely for a while is an effective way to get them on the right track.I encounter pointers pretty frequently. Some common design patterns like bridge, PIMPL, and factories rely on them. In multi-threaded programming, it is often necessary to store pointers for functors/closures. And of course there are times when you absolutely need to allocate something from the heap - again, with asynchronous programming this happens very often.
Pretty simple solution. But when I tried to use it for templates it was a bit messy (having to do multiple if statements for start and end html tags).Just store the date, if everything is stored by date and round.
Code:$date = ''; foreach($games as $g) { // Output the date/round once if ($date != $g['date']) { echo $g['date'] . "\nRound " . $g['round'] . "\n"; } // store the date $date = $g['date']; printf("%s %d - %d %s\n", $g['team_1'], $g['score_1'], $g['score_2'], $g['team_2']); }
$dates = array();
foreach ($games as $game) {
$date = $game['date'];
$dates[$date][] = $game;
}
foreach ($dates as $date => $games) {
echo $date;
// <table>
foreach ($games as $game) {
// <tr>
// <td>
echo $game['user_1'];
// </td>
// <td>
echo $game['user_2'];
// </td>
// </tr>
}
// </table>
}
Which language will be used in the class? I would recommend learning a little bit of that.What's the best place to start learning about programming? I'm working towards a computer science degree and will be taking an intro to programming in the spring semester, but I'd like to start getting my feet wet now so I can have a head-start when starting the course. I have absolutely no prior knowledge to programming.
One problem with a broadcast topology is that if two hosts transmit at the same time, then their signals collide, and no communication takes place. Suppose you have a bus topology with TWO hosts. During each time-slot, each host will attempt to broadcast a packet with uniform probability p = 0.25. What percentage of time slots will be wasted due to a collision? Explain your answer.
.text
.globl main
main:
move $t0, $sp # keep record of sp
subu $sp, $sp, 32 #Stack frame is 32 bytes long
move $t1, $sp # what
sw $ra, 20($sp) # Save return address
sw $fp, 16($sp) #save old frame pointer
addiu $fp, $sp, 28 #set up frame pointer
li $a0, 10 # put argument (10) in $a0
jal fact # call factorial function
la $a0, $LC #put format string in $a0
move $a1, $v0 #move fact result to $a1
[U][B]jal printf # call the printf function -- This is where the problem is!![/B][/U]
lw $ra, 20($sp) #restore return address
lw $fp, 16($sp) #restore frame pointer
addiu $sp, $sp, 32 #pop stack frame
jr $ra # return to caller
.rdata
$LC:
.ascii "The factorial of 10 is %d\n\000"
.text
fact:
subu $sp, $sp, 32 #Stack frame is 32 bytes long
sw $ra, 20($sp) #Save return address
sw $fp, 16($sp) # save frame pointer
addiu $fp, $sp, 28 #set up frame pointer
sw $a0, 0($fp) #Save argument(n)
lw $v0, 0($fp) #load n
bgtz $v0, $L2 #branch if n>0
li $v0, 1 #return 1
jr $L1 # Jump to code to return
$L2:
lw $v1, 0($fp) #load n
subu $v0, $v1, 1 #compute n-1
move $a0, $v0 #Move value to $a0
jal fact #call factorial function
lw $v1, 0($fp) #load n
mul $v0, $v0, $v1 #compute fact(n-1) * n
$L1: #result is in $v0
lw $ra, 20($sp) #restore $ra
lw $fp, 16($sp) #restore $fp
addiu $sp, $sp, 32 #pop stack
jr $ra #return to caller
"Weird math stuff"? Really?This might not be the best place to ask this since it's a Networking class question but I just don't know how to do this.
Never worked with weird math stuff like this.
Edit: My only guess is (0.25)*(2 hosts). But I really have no idea.
This might not be the best place to ask this since it's a Networking class question but I just don't know how to do this.
Never worked with weird math stuff like this.
Edit: My only guess is (0.25)*(2 hosts). But I really have no idea.
"Weird math stuff"? Really?
The chance that host A transmits is 25%. If host A transmits, the chance is 25% that host B also transmits, hence the chance that both transmit is 0.25*0.25 = 0.25^2 = 0.0625 = 6.25%
Basically it's asking what are the chances that both are transmitting at the same time. So 0.25 * 0.25 would tell you the probability of it happening. So 0.0625 or 6.25% of the time they would be having a collision.
Hi. I don't know assembly, but it looks like printf isn't defined anywhere else in the program. If you look at another similar example, where it says "jal fact", it's calling (jumping to?) the factorial function. There's a part near the bottom where fact is defined, starting with "fact:" There is no such place for printf. It's missing.Hey you guys, I'm having trouble running this mips assembly program on qtspim
For some reason it keeps coming up with the error:
"Instruction references undefined symbol at 0x00400048
[0x400048] 0x0c000000 jal 0x00000000 [printf] ; 15: jal printf"
This is when printf is called I guess.
I copied this code out of the book I'm reading here on pages A-27 to A-29
If anyone could help me out then that would be a big help!!
Edit: Also, for clarification, this program calculates 10! and then prints the result out.
Hi. I don't know assembly, but it looks like printf isn't defined anywhere else in the program. If you look at another similar example, where it says "jal fact", it's calling (jumping to?) the factorial function. There's a part near the bottom where fact is defined, starting with "fact:" There is no such place for printf. It's missing.
I know, I'm not sure whether I am supposed to define it myself or if there is supposed to be some kind of preset printf macro. The book isn't clear on this and it doesnt show you how to define it(if you do need to).
I'm sure some of you are college students. Does anyone know the deal with the free windows 8 that comes from dreamspark? I downloaded and plan on upgrading to it but idk the restrictions that come with it since its from dreamspark.
I don't think there are any restrictions. My copy came from dreamspark. I assume there's something about not using it for commercial blah blah, but it seems to be a fully functioning Win 8.
OK cool. I did a compatibility test and the only thing that came was the dvd issue and that my firmware doesn't support secure boot. Any issues with secure boot not being present on my machine??
The example you are seeing in the book is an excerpt, not all of the C code you need for it to work, nor all of the assembled code. They are attempting to show you what a subset of the MIPS code would look like for illustrative purposes. The MIPS code is not intended to be runnable on its own.
printf is defined in the C standard library. The C code shown in the book would need to include stdio.h. The linker then combines object code generated from the compiler with the pre-compiled object code in the standard library (which contains the code for printf).
If you want that example to work, you need to do the following:
1. Compile the MIPS assembly code into object code.
2. Link the object code with a MIPS version of glibc
This isn't a good template at all, but just cycle through each game individually instead of having PHP do the key => val technique.Pretty simple solution. But when I tried to use it for templates it was a bit messy (having to do multiple if statements for start and end html tags).
So I figured for templates it would probably more easy with foreach in foreach and worked my way backwards from that.
Thanks for your input.
Code:$dates = array(); foreach ($games as $game) { $date = $game['date']; $dates[$date][] = $game; } }
foreach ($dates as $d) {
echo "<table>";
foreach ($d as $g) {
echo "\n <tr>\n";
printf('<td>%s</td> <td>%d</td> <td>%d</td> <td>%s</td>', $g['team_1'], $g['score_1'], $g['score_2'], $g['team_2']);
echo "\n </tr>";
}
echo "\n</table>";
}
After you do that get Visual Studio 2012. I got the professional version for free. Blew me away that Microsoft would let me do that.I'm sure some of you are college students. Does anyone know the deal with the free windows 8 that comes from dreamspark? I downloaded and plan on upgrading to it but idk the restrictions that come with it since its from dreamspark.
Would have to determine the rules, which I always forget, but would just be a series of nested if-thens to add to a final total, as you iterate over the spliced string. Would have to start at the left and then compare the digit to the left and right to determine if you add or subtract it.
Oh you're talking to the banned guy![]()
#!/usr/bin/perl
# roman.pl
use warnings;
use strict;
#XL = 40; L = 50; XC = 90; C = 100
my $value=0;
print "Enter a Roman numeral: ";
chomp(my $input=<STDIN>);
my @array=split("", $input);
my $temp_var="NULL";
for ( reverse(@array) ) {
if ($_ eq "I" && $temp_var eq "V") {
$value-=1;
} elsif ($_ eq "I" && $temp_var eq "X") {
$value-=1;
} elsif ($_ eq "V") {
$value+=5;
} elsif ($_ eq "L") {
$value+=50;
} elsif ($_ eq "C") {
$value+=100;
} elsif ($_ eq "X" && $temp_var eq "L") {
$value-=10;
} elsif ($_ eq "X" && $temp_var eq "C") {
$value-=10;
} elsif ($_ eq "X") {
$value+=10;
} elsif ($_ eq "I") {
$value+=1;
}
$temp_var=$_; # access temp var (previous value) in above operations
}
print "$value\n";
One of the courses over on Edx (MIT's 6.00x Introduction to Computer Science and Programming), Coursera (Rice University's an introduction to interactive programming in python, starts next month) or Udacity (University of Virginia's intro to CS).What's the best place to start learning about programming? I'm working towards a computer science degree and will be taking an intro to programming in the spring semester, but I'd like to start getting my feet wet now so I can have a head-start when starting the course. I have absolutely no prior knowledge to programming.
After only studying basic C in college, I'm faced with a nasty assignment in Grad School.
Could someone explain what an anchor node is in reference to a circular double linked list?
This isn't a good template at all, but just cycle through each game individually instead of having PHP do the key => val technique.
@foreach ($dates as $date => $games)
<table>
<thead>
<tr>
<td colspan="5">{{ $date }}</td>
</tr>
</thead>
<tbody>
@foreach ($games as $game)
<tr>
<td>{{ $game->league }}</td>
<td>{{ $game->round }}</td>
<td>{{ $game->user_1 }}</td>
<td>{{ $game->score_1 }} - {{ $game->score_2 }}</td>
<td>{{ $game->user_2 }}</td>
</tr>
@endforeach
</tbody>
</table>
@endforeach