void main(int argc, char* argv[])
{
printf("%d\n", x());
getchar();
}
int x(void)
{
return rand() % 10;
}
Type: Posts; User: Princeton
void main(int argc, char* argv[])
{
printf("%d\n", x());
getchar();
}
int x(void)
{
return rand() % 10;
}
Both are worth having simply because they serve different purposes. The former is a language reference that comes close to the C standard in accuracy while still maintaing an approachable air. There...
>I was already wondering why it was saying "integer without a cast".
That is a sign that a function is being used before its declaration. Without a declaration, functions are assumed to return int,...
>void add() = a function that has no return and has an unspecified number of parameters.
>int function(void) = a function that has an int return and no parameters.
It really depends on whether or...
>arg= argument?
>So whats the 'c' and the 'v' after arg?
argc == argument count
argv == argument vector
In theory you may name the arguments whatever you like, argc and argv are merely common...
>>Is it possable, that user types there file, and program would open/create file named file.txt?
Yes, however you would be required to append the appropriate extension before opening the stream.
...
>>Google for 'ifstream' and 'ofstream'.
With the extraordinary numbers of bad examples I would hesitate to suggest this. Perhaps a direct link to a well known high quality example would be better....
>>The ".h" header suffix has been phased out as a c++ standard.
conio.h is not a standard header, so that change does not apply.
>>what is the diference between the endl,flush
endl will print a newline and flush the stream, flush will not print a newline and flush the stream.
>>this is the princeton's way!!!
Well, it is...
>>so say if(!strcmp(m[],n[])
if (strcmp(m, n) == 0)
Or the equivalent but arguably less clear
if (!strcmp(m, n))
However, in this case because the arrays are not terminated by a null...
>>if ((cfPtr = fopen("clients.dat","r") == NULL)
Your parentheses are not balanced. This is what you want.
if ((cfPtr = fopen("clients.dat","r")) == NULL)
>>OH, it's a tip "int instead of void" or rule ?
It is a rule. The C++ standard requires main to return an integer except in very specialized implementations where it imposes no restrictions. The...
Did you remember to include windows.h?
Red Hat and SuSE both offer the parted utility if I recall correctly, so it is possible with both.
If you use the new headers then you must also remember that every standard name is embedded within the std namespace.
#include <iostream>
using namespace std; // Add this for the easiest fix...
If you can manage to acquire a second hard drive then it would be much easier to simply use that for Linux and leave the Windows drive unchanged. However, Mandrake does support a feature that allows...
>>int sum = ONE + TW0;
The letter O can be easily confused for the number 0. The define is TWO yet you used TW0. Feel free to change your viewing font if the two still look identical.
Yes, you are right. I should have been more specific so as to avoid bashing the tool. However if the design of a function does not lend itself to being used correctly then it most certainly is a...
>>What i was wondering is it possible to dynamically create these array[][] varibles
Yes, of course.
int **array = new int*[rows];
for (int x = 0; x < rows; x++) {
array[x] = new int[cols];...
>>but isn't that a problem with scanf then?
Yes, it is a problem with scanf. But it is not unique to scanf. The same problem can occur with any input function that reads a single character and does...
Try using the same solution after every call to scanf and see if the problem persists. scanf is a very complex function that is difficult to use properly even for experienced programmers. Once again...
Or better yet, modularize each operation into a specialized function so a proper solution can be used without cluttering the main function. :)
#include <ctype.h>
#include <math.h>
#include...
The problem is not necessarily with scanf, but character input in general. When you ask an interactive user to enter a single character, two are actually placed on the input stream. The first is the...
>>If classes only modified their own data - wouldn't this limit all the cool stuff classes can do?
Some would argue that the "cool stuff" is undesirable from a design standpoint. In my experience...
It is possible to have a reference member within a class, but you will need to take more care in the constructor because references must be initialized upon creation. Fortunately, a constructor...