For the course on C I did last year, we had to draw 'memory diagrams'. Not sure if that's the same thing, but it meant basically drawing rectangles representing memory locations for each variable and...
Type: Posts; User: lemnisca
For the course on C I did last year, we had to draw 'memory diagrams'. Not sure if that's the same thing, but it meant basically drawing rectangles representing memory locations for each variable and...
Also, you have "If" with a capital 'I'. It needs to be lowercase "if".
Your for loop goes through every integer up to half the number you are testing to see if it is a factor. If it is, then the number cannot be prime. Note that it is actually only necessary to go up to...
And you should always check the return value of malloc, like so:
if((p = malloc(sizeof(int) * size)) == NULL)
exit(1);
/* And print a useful error message if you want */
In practice,...
If it's a function you're writing, you can write it to accept a variable number of arguments and use function pointers as fgw_three said, but I don't think it's possible if it's some arbitrary...
On the line after your while, you have an opening brace with no matching closing brace. This is probably what's causing your compiler to complain. The code would be much clearer to you, and you would...
oh, indeed...that's just me not checking the code I post carefully enough. It should, of course, be fmt[10] = '\0';. This is why I always turn on plenty of warnings when I compile...:)
The other thing you can do with printf is generate your format string beforehand to include however many spaces, backspaces etc. you like. You can use sprintf, strncat and so on inside loops to build...
I think how you lay it out is pretty much up to you, but it's a good idea to make it logical, readable, and consistent. So have things that relate to each other be close together, use good...
You can get one character of input using getchar(). Suppose you do:
int c;
c = getchar();
you can then simply do:
if(c == 'y)
/* do something */
else if(c == 'n')
/* do something...
main() is where the program starts. Without main, how would it know where to begin? Would it just pick a random function and hope for the best? main() defines a starting point.
The thing reporting...
Did you try moving it to the start of main? If you remove the printf it would then be at the start, this is probably why it works when you do that. Also it will work when it's outside of main because...
Try putting the struct declaration at the start of main, instead of after the printf statement.
When I compiled this code with gcc, I got:
$ gcc -Wall -pedantic -ansi tarotcard.c -o tarotcard...
I'm studying electrical engineering and also have a C course as part of my degree requirements, nearly finished the C course now, only the exam to go. Not sure what you're asking here though. I would...
Wouldn't it be easier to do what, for instance, Matlab does and simply store the polynomials as an array? The length of the array is the degree of the polynomial plus one, and each element of the...
Firstly, note that ~ isn't the only thing that bash expands - in fact, bash does a great deal of mucking around with the user input before the command actually gets executed. If you want to do all...
cat foo.c | sed s/float/long long/g
:P
long or long long will most likely be precise enough for you, but if you're not satisfied with that, then I suppose you'll have to use a library (or write...
Ok, that's your assignment...but what's your question? What are you having trouble with?
If you don't know where to start, this might be a good place to begin reading:...
If you want more accuracy, maybe use a different data type instead of float?
Laziness can often be a virtue in a programmer - sometimes it makes the difference between someone who will manually copy and paste many lines of code and change one value per line, and someone else...
But how do you know that just because it isn't morse code it is valid input? If I was writing it I would do two checks - one for morse code and if it fails that, one for valid text. Otherwise who...
SlyMaelstrom: You could of course read into another variable, I just figured he wouldn't want to do anything with line if the input was invalid, and if it is valid, line will not change.
...
line is a character array, you can't compare it to a single char.
However you can easily test if the line consists only of letters, or only of dots and dashes. You can iterate through the array...
Did you read dwks' post?
charNode *W = start->next->next;
charNode* E = start->next->next;
You have two pointers to the same node.