Im 1/5 of the way to block 3 since you last gave me some. It doesnt take long.
It surely doesn't take long when people are giving it out for free. And then it tends to correlate with post count, which "stands for nothing."
Im 1/5 of the way to block 3 since you last gave me some. It doesnt take long.
It surely doesn't take long when people are giving it out for free. And then it tends to correlate with post count, which "stands for nothing."
The trend is not surprising at all. Debian has a niche for servers, being that it runs older, more stable packages. Ubuntu has more appeal for desktop users and is making a name for itself in its attempt to draw users from the Windows userbase. However, few sysadmins will be willing to use Ubuntu as a server for a while, mainly because of it's use of new and not as proven packages (notice the security alerts for Ubuntu on the Google Trends page). There are a few people who used to use Debian for their desktop who may switch to Ubuntu.
Or, you could just pass it as a pointer. And either way, you'll want to pass some sizes with it to make sure you stay within your allocated memory.
Go with the new font. If it really really bugs a small group of people that much, there's probably a way to change it in their browser (e.g. I think Firefox has some plugin to apply custom CSS to pages).
As for those saying to put it in the CP, while that's a nice idea, it's not always feasible. The CP should be kept simple and trivial things (such as this IMHO) need not clutter it up.
I just get warnings rather than errors, but the problem is pretty simple. You're missing a declaration of funct. In C you need to declare (if not define) a function before calling it.
#include<stdio.h>
void funct(char*);
int main(int argc, char **argv)
{
FILE *fp1 = fopen(argv[1], "w");
fprintf(fp1, "Hello");
funct(argv[2]);
fclose(fp1);
}
void funct(char *fileToOpen)
{
FILE *fp2 = fopen(fileToOpen, "w");
fprintf(fp2, "Hello");
fclose (fp2);
}
Let's see if I finally get this correct for once:
int array[3];
array[0]
array[1]
array[2]
array[3]Four elements in an a single dimention array.
No. Valid indices would be 0-2, for a total of 3.
int array[3][2];
array[0][0]
array[0][1]array[1][0]
array[1][1]array[2][0]
array[2][1]Correct?
Yes
When you allocate an array, it basically tells the compiler "I want an array of N objects of type T". The compiler will lay those out in memory like so:
int arr[5];
| 0 | 1 | 2 | 3 | 4 |
Then when you index into the array, it takes the address of the first element of the array and adds the index to that address (it moves the index by the appropriate size of the data type, e.g. 1 byte for char, 4 bytes for a 32-bit int, etc..)
int arrayOfArrays[2][3]
will make an array of 2 integer arrays of length 3 each. A 2x3 if you will.
could you post the code please? And be sure to use [code] and [/code] tags :)
You just pass argv[2] to the function:
void function(char* fileToOpen);
int main(int argc, char** argv) {
FILE* fp1 = fopen(argv[1], "w");
function(argv[2]);
}
void function(char* fileToOpen) {
FILE* fp2 = fopen(fileToOpen, "r");
// ...
}
i couldn't figure out how to keep testing for new integers, then doing a sum at whatever point an EOF is encouintered ( or perhaps a zero?).
The only way seemed to invole breaking the element insert loop.
I have been told that this is BAD PRACTICE!!
Whoever told you that was wrong. If you're going to take an arbitrary number of inputs, you need to let the loop go until you read an input telling you to stop (e.g. 0). Of course, this makes your marker an invalid input for the middle of the list (since it would break the loop), which is a consideration you have to make.
For the code block styling, I do like the auto-wrapping for long lines, but sometimes it would be nice if there was a scrollable div for the code. Not all of us have 30" monitors, and when someone posts 100+ lines of code it would be nice to limit the amount of scrolling necessary to get past their code. Just my $.02 on that...
The font sizes are fine to me. I prefer a slighly larger size just because it's easier on the eyes. And I'm still to young to be wearing those out :P
iamthwee makes a good point. The fix I provided will only be moderately effective at best, with decreasing effectiveness as you try to build a longer list (since you have to search the list each time and have more chances of a duplicate).
Also, neither of these will work if you were to build a list over 5000, for obvious reasons. And by disallowing duplicates, the array is technically not random :icon_wink:
Ah, I see it now. When I ran it with MAXSIZE of 20 on my machine that didn't come up. The problem is here:
void FillMainList(int list[])
{
int temp, test;
for (int i=0; i<MAXSIZE; i++)
{
temp = (rand() % 5000);
test = LinearSearch(list, temp);
if (test == -1) // if the new value isn't in the list
list[i] = temp; // then save it
// otherwise.... it'll skip this index and you'll have the uninitialized value
}
}
To fix that, you should put the random generator in a loop and use the LinearSearch results as a loop condition:
for(int i = 0; i < MAXSIZE; i++)
{
do {
temp = rand() % 5000; // get random number
} while (LinearSearch(list, temp) != -1); // repeat till it's unique
list[i] = temp; // save it
}
• You need to break out of the loop in your linear search if the required value is found.
He sets a boolean flag :icon_wink:
with some code or description of what you've attempted
I don't see anything particularly wrong with your code. Two things I do see though:
- By using the same seed, you'll always get the same list of numbers. Most people solve this by using the current time as a seed.
- Using the global constant MAXSIZE is probably bad style. It's fine for creating the array, but you should restructure your other functions to take an array and it's size as parameters, and then use that size value for your loop condition. This will be more adaptable to different sized arrays and especially useful if you deal with dynamic arrays.
Oh come on, I hope you are not talking about performance issues here. Either that or I missed your point completely... ;-)
A small part of it was performance, but that point is nearly moot these days. I was thinking more along the lines of matching a paradigm to a problem and to library availability and ease of use.
Have you tried running chkdsk or any other disk integrity checkers? It's possible that one of these may notice something's up and hopefully even repair the situation.
You'd have multiple definitions of main, which is an error.
A few other points:
- main's return type should be int.
- you should never include .c files. The compiler will create object files (.o or .obj, possibly others depending) and then the linker will put the pieces together. However, functions and structs should be declared (but not necessarily defined) in .h files, which you should #include as needed.
- Try to avoid using conio.h and the functions therein. They are not available with most compilers and hence other people cannot run your code as is. Look into input methods with the standard I/O libraries.
I thought the giveaway was the red capital letters at the bottom "THIS FORM IS FOR ENTERTAINMENT PURPOSES ONLY" :icon_razz:
Pretty funny though :D
when you get a lot of posts to you get another green rep power
Actually not. It was recently discussed in another thread, but you get reputation when other members give it to you. How much you get is determined by a variety of factors.
[tex]69 = 13^2 - 100[/tex]
Using modern languages like Ruby, Python etc is the way to go. They are much less of a headache.
When they are appropriate. :icon_wink:
If you're using C++, you should probably be using the std::string type rather than C-style strings (char*).
And your line strlen(getWord) = numLetters;
is backwards. Try flipping it around. ;)
I think you'll just have to search through it one bufferSize at a time... you'll certainly have to read it to see where the data is...
The .NET framework is a set of libraries that Microsoft provides for developers. It's similar to the Java libraries in that it essentially requires a host environment to be installed before you can use applications written with it (e.g. you need to have .NET framework installed to run .NET apps ~ you need JVM to run Java apps).
As to compilers, try them each out and decide which you like better. Or if you're comfortable with your first pick, just use that. Everyone'll have their own preference. I prefer VC++ (I have the full version though), but I've not even tried the others. ;)
It took me a couple months to realize Daniweb even had ads... :cool:
I take a long time to write code too, mainly because I test it in my head as I write it. I still come up with plenty of bugs too, which then takes time to hunt down and fix. It's not like we're all computers, afterall ;)
Btw: What determines how many points you get from a single rep? Like say, someone gives me a good rep, but it only boosts it up a point. But if someone else gives me a good rep, it boosts it up 10 points. [?]
Again speculating on how it works: if you get rep from someone with little rep of their own, you get a small number of points. If you get rep from someone who has a lot of rep, you get more points. This is a really cool dynamic, since the people that have lot of rep are less likely to be impressed by a post than those little rep, and so it adjusts accordingly.
You pretty much search the array and see if the item is in it or not. If the array is sorted, a binary search will do this pretty fast. If it's not sorted, you have to loop over each object in the array:
for(int i = 0; i < arraySize; i++)
// check if array[i] == itemToFind
Aside from ;) I like them. That one just looks... I dunno... wrong... :-/
Serious discussions in the Geeks Lounge...you have got to be joking. The only serious discssions are those discussions which turn into a flame war and we don't get to see a lot of them nowadays...;)
Hm... that would make it tough to get more rep, huh.... :p
Since you didn't give much spec aside from the description, here's some rough pseudo-code:
int main(int argc, char** argv) {
// should check for the right number of arguments before going past this point
ofstream outfile(argv[argc - 1]); // last argument
for(int i = 1; i < argc - 1; i++) { // loop over small files
ifstream infile(argv[i]); // small file
read from infile and write to outfile, probably in another loop
infile.close();
}
outfile.close();
return 0;
}
Obviously, I left a lot out, but hopefully you get the idea :)
I guess I'm just not insightful enough ;)
I'd venture that you won't have as much of a chance to demonstrate your insight in all the games. Almost all of my rep has come from the programming sections, where I can throw out bits of information better. 'Course, not everyone here's a programmer, but even in serious discussions in the Geek Lounge you'd probably have a better chance of getting more rep. ;)
> Is it just me, or have I totally lost the focus of this thread...
This is one of the better hijacking's I've come across lately too.
I think the rep system is fine the way it is. People catch on quickly enough, and those who know about it tend to use it enough.
Floating point numbers are not stored precisely in memory. They are usually stored according to the IEEE 754 standard. If you want exact precision, you need to use a 3rd party library or write your own. For most calculations, however, the small degree of error is acceptable.
When you use a variable twice in an expression and one of those instances is a pre- or post- increment, the behavior is undefined (and then depends on how it's implemented by your compiler).
thanks infarction. I would use this, but we havn't gone over any limits and are just studying namespaces this chapter. Thanks though =)
I'll just go with it, thanks dragon.
The limits thing was just to pull out a compiler specified degree of accuracy. Since floating point numbers aren't stored precisely in memory, you can't use == and != with much accuracy. You can specify your own degree of accuracy and do similar to my post to check if numbers are [un]equal (within that degree of accuracy).
The one problem I see is that you can't compare floating point numbers directly. Here's a re-write with slightly different logic (you can keep yours if you want, they're about the same) and a better way to compare the doubles:
#include <cmath>
#include <limits>
triangleType triang(double a, double b, double c)
{
const double eps = std::numeric_limits<double>::epsilon();
triangleType shape = scalene;
if( fabs(a - b) <= eps && fabs(a - c) <= eps)
shape = equilateral;
else if( fabs(a-b) <= eps || fabs(a - c) <= eps)
shape = isosceles;
else if ( a > b + c || b > a + c || c > a + b) // this could be first like you had it
shape = noTriangle;
return shape;
}
Admittely, I just copied the epsilon thing from some google result, so I don't know if that's the correct way to go about it.
How many reps does it take to get a block?
AFAICT 100 rep points per block. That's just based on looking at my own though, so the data set is quite limited.
[tex]\frac{3}{-3} = -1[/tex]
I've heard lots of good things about the Vaio. One of my friends has one, and it seems to work pretty well for her.
>A have a friend who (used to) have an AMD64 processor in his laptop. It had a 17" screen, battery life for
>around 1 hour, wicked fun... :twisted:
Yeah, this guy I know has dual P4 3.6's in his Alienware box. It's really a portable desktop, I'd not want it on my lap :p
But, It might be better to make a new thread titled "Chemistry Game" anyways...
There's enough game threads as is. You can share. :twisted:
>If they do this by playing games then so be it, not a great problem.
It's a little insulting though, to have members who play word games that have way more posts than the people who spend time helping other people. To be fair, I don't mind it when "helpful" people post in word games, it just bugs me when member's post counts consist almost purely of word games.
I totally agree, but here at Daniweb it's not as bothersome as everywhere else. The reputation system seems to work fairly well, so you can see via means other than post count who is helping people and who isn't. You can even tell who spends most of their time playing word games :P
And if people aren't posting just to increase their post count, as you say, then why would they care if posts in word games didn't increase their post count?
Quoted For Truth
I think you could use freopen to do it somehow... I'm not sure that it'll work, but hopefully it'll at least be a starting point.
The freopen() function opens the file whose name is the string pointed to by path and associates the stream
pointed to by stream with it. The original stream (if it exists) is closed. The mode argument is used just as
in the fopen() function. The primary use of the freopen() function is to change the file associated with a
standard text stream (stderr, stdin, or stdout).
hm... I already have 560-someodd yet still only two blocks of rep power... I must have been wasting too much time... :twisted:
uh, josh, how did that fit the thread rules? :p
[tex]\infty = lim_{x \to 0}\frac{1}{x}[/tex]
good luck to the next person :twisted: