So I've got a homework assignment in my University course that is giving me a lot of problems.
Given a Directed Graph G we have to determine if the graph is sortable (Each vertex with indegree > 0...
Type: Posts; User: Tomwa
So I've got a homework assignment in my University course that is giving me a lot of problems.
Given a Directed Graph G we have to determine if the graph is sortable (Each vertex with indegree > 0...
I'd also like to add the following C++ Tutorials.
C++ Tutorial - Introduction to C++ - Cprogramming.com
If Statements in C++ - Cprogramming.com
For, While, and Do While Loops in C++ -...
1) No idea I've not had much practice with the functions in the POSIX standard.
2) Don't print the entire buffer? Print until a null terminator.
write(fd,buffer,sizeof(char)*strlen(buffer));
Problems:
1) Change is incremented before it is initialized
int change = 0; when defining is necessary (or set it to 0 before using it at some point)
2) Your final printf is using k instead...
Beat ya to it ;)
@chihwahli
I'm a little confused on your end goal here but I'll give it my best shot to answer what your asking.
When you read memory all your doing is grabbing the appropriate number of bytes,...
You were almost there :) things just went a little screwy
1) fflush(stdin) is undefined behavior as fflush is meant to be used for output streams
FAQ > Why fflush(stdin) is wrong - Cprogramming.com
2) You're trying to store ints in your buffer...
The funny thing is I think Matticus meant to call him out on him writing the code but ended up linking him to the working code instead
I'm pretty sure you just googled the answer for him :wink:
What purpose would there be in giving you code for an interview? Even if we did give you the full and working code (Which isn't that hard) you'd never be able to perform the job. My guess is this...
I love how hostile people are on here, you act as though the OP said "Write me a program that gets the value of money from the number of coins" and I just did it, in reality a user posted his NEARLY...
The best way to learn is through practice, I'm glad you learned from this as that's without a doubt the best thing you could've gotten from posting on here. There are plenty of great tutorials on the...
Glad it helped, sorry my responses were so funky last night, I'm feeling (a little) better today after some rest :)
@grumpy the largest part of your example tends to lean toward code which isn't properly factored and has the definitions extremely far from their usage (Ideally it wouldn't be more than a few lines)....
Honestly I think I'm losing it -.-
I'm amazed I'm the first to catch that.
99% of that code is his, Technically he had a working solution (Did the math and received input), and I improved on it by adding sscanf/fgets, the use of toupper to remove the need to compare to...
The OP didn't specify whether or not he wanted to comply with any standard and as his original post contained getch I assume he accepts it as reasonable (Thought pointing out that it is non-standard...
Ah you've got me there! It's still a good practice though.
I also want to point out that I accidentally dropped the getch() keeping the console window open so the OP needs to amend that into the...
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main(void)
{
double num1 = 0;
double num2 = 0;
// Operand is a character not an array of characters.
char...
Edit: sorry didn't expect 10 people to beat me to it -.-
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
double num1 = 0;
double num2 = 0;
// Operand is a character not...
Your primary issues were:
1) Failed to initialize your variables, when you create a variable memory is allocated for that variable by the operating system, there is however no guarantee that the...