Forum: C 6 Hours Ago |
| Replies: 5 Views: 82 That kind of masking works just fine; it might be expressed more simply:
void *ans = (void*)((unsigned long)addr & ~0xfffUL);
(At least as far as manipulating bits of an integer. I don't know what... |
Forum: C 9 Hours Ago |
| Replies: 3 Views: 65 Used unsigned integral types when dealing with bits.
#include <stdio.h>
#include <stdlib.h>
int main()
{
unsigned short m1 = 0xf000, m2 = 0x0f00, m3 = 0x00f0, m4 = 0x000f;
printf("%hu... |
Forum: C++ 1 Day Ago |
| Replies: 5 Views: 163 time is a reserved identifier. |
Forum: C++ 3 Days Ago |
| Replies: 5 Views: 144 Huh?
If you're trying to open the file for input, you use this bit here:
ifstream inputFile;
Open the file and read it? |
Forum: C 3 Days Ago |
| Replies: 3 Views: 139 Use strcpy to copy a string. You've got more going wrong in that code, though. I think you're after something that might look a bit like this:
#include <string.h>
typedef struct
{
int age;... |
Forum: C++ 3 Days Ago |
| Replies: 2 Views: 111 How about a final else?
And don't use the comma here:
else if (numtick >100,000) |
Forum: DaniWeb Community Feedback 3 Days Ago |
| Replies: 7 Views: 186 Right. In every other forum I frequent, I change the font to Courier New. Once upon a time, we could do that here. And that is what I was trying to say. |
Forum: DaniWeb Community Feedback 3 Days Ago |
| Replies: 7 Views: 186 One way it was done ages ago elseweb was [code], [quote], and [syntax]. The syntax tags were used for the "fancy" code tags. Quote in monospace to me would look stupid.
[edit]Keeping the fonts,... |
Forum: C++ 4 Days Ago |
| Replies: 20 Views: 290 Related:
http://parashift.com/c++-faq-lite/input-output.html#faq-15.4 |
Forum: C++ 4 Days Ago |
| Replies: 6 Views: 153 Well, choose your poison: multiple passes of the same file, or a single read with a buffer. Both are relatively simple, I'd recommend just examining what's there. Experiment a bit. Learning to code... |
Forum: C++ 4 Days Ago |
| Replies: 6 Views: 153 I suppose you could read the file to count the lines and then back up and only print the last 10.
Why the extra condition now?
Why don't you give the coding a shot first? |
Forum: C++ 4 Days Ago |
| Replies: 6 Views: 153 I'd just read all lines of the file into a circular buffer with 10 strings, each containing a line. When you get to the end of the file, you will have the last 10 lines stored.
#include <iostream>... |
Forum: C 4 Days Ago |
| Replies: 5 Views: 159 You'll need to make a lot of changes to your functions given this sort of pattern...
From (extraneous type needs to be removed, multiplication is done using *, feed the pow function the correct... |
Forum: C++ 5 Days Ago |
| Replies: 20 Views: 290 Well, if you don't get an integer because the user didn't enter a valid one, then "(x>0)" makes no sense either. You can do it your way by recognizing input failure and cleaning up the input stream.... |
Forum: C++ 5 Days Ago |
| Replies: 20 Views: 290 I think the basics are here:
http://www.daniweb.com/tutorials/tutorial71858.html |
Forum: C++ 5 Days Ago |
| Replies: 20 Views: 290 My usual advice is to always read all user input as a string. If you want a numeric value, attempt to perform a conversion. If the conversion fails, issue a message or something; otherwise you... |
Forum: C 5 Days Ago |
| Replies: 2 Views: 155 fmod (http://web.archive.org/web/20050207005628/http://dev.unicals.com/papers/c89-draft.html#4.5.6.4) |
Forum: C++ 6 Days Ago |
| Replies: 12 Views: 238 You're going to return from main in one of two places:
int main ()
{
int number;
int counter = 0;
int flags = 1;
bool flag_none = true;
bool fag_yes = false;
cout << "Enter a number,... |
Forum: C 6 Days Ago |
| Replies: 4 Views: 112 I don't see that return c; line. |
Forum: C++ 6 Days Ago |
| Replies: 12 Views: 238 The following code is unreachable:
if (counter < 7 == true)
{
cout << "Number " << counter << " is between 10 and 500" << endl;
cout << "Number " << counter << " is not flagged. " << endl;
}... |
Forum: C++ 6 Days Ago |
| Replies: 12 Views: 238 |
Forum: C 6 Days Ago |
| Replies: 4 Views: 112 while((c = getchar())!= EOF)
And what does your function return for non-alpha input? |
Forum: C 6 Days Ago |
| Replies: 3 Views: 146 team temp[1];
This has only one element: temp[0].
temp[1] = teams1[(j-1)];
teams1[(j-1)] = teams1[j];
teams1[j] = temp[1]; |
Forum: C++ 7 Days Ago |
| Replies: 3 Views: 131 http://en.wikipedia.org/wiki/Comparison_of_text_editors |
Forum: C 7 Days Ago |
| Replies: 3 Views: 158 |
Forum: C 8 Days Ago |
| Replies: 11 Views: 404 C89 is de facto standard for C, and it is also the base of the current C++ standard. |
Forum: C++ 8 Days Ago |
| Replies: 3 Views: 120 It could possibly be a gcc issue.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13741 |
Forum: C++ 8 Days Ago |
| Replies: 3 Views: 120 I get an odd warning:
switch ( opcion ) // warning: unreachable code at beginning of switch statement
{
case 1:I think this has something to do with using the language extension VLA:
float... |
Forum: C++ 9 Days Ago |
| Replies: 7 Views: 245 The template thing is kind of a funky in-between in which an accepted solution is to in fact put the active code in the header: |
Forum: C 9 Days Ago |
| Replies: 2 Views: 162 Hmm.
But x should be an int, as that is what getchar returns. |
Forum: C 9 Days Ago |
| Replies: 2 Views: 210 Clean up the leftover newline in the input stream. |
Forum: C++ 9 Days Ago |
| Replies: 7 Views: 245 I had to patch some syntax errors to get to the link, so I'm not sure why you weren't seeing them. With regard to the linker errors:
http://parashift.com/c++-faq-lite/templates.html#faq-35.12 ? |
Forum: C++ 11 Days Ago |
| Replies: 7 Views: 163 Just sayin'.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
/* Extract value for # of elements in array */
int i; |
Forum: C++ 11 Days Ago |
| Replies: 7 Views: 163 fin.open("numlist.dat");
fout.open("numlist.dat");
Perhaps first open for input. Then after you've extraced what you want and closed the file, then open the same file for output. |
Forum: C++ 11 Days Ago |
| Replies: 9 Views: 202 You might find such a thing here, perhaps in the snippets, maybe a previous forum thread. So a search might be helpful to you. |
Forum: C 11 Days Ago |
| Replies: 2 Views: 172 This is array of pointers to string literals:char *MONTH[] = {"January","February","March","April","May","June","July","August","September","October","November","December"};String literals are not... |
Forum: C 11 Days Ago |
| Replies: 5 Views: 219 int main()
{
FILE *filetext;
FILE *filecopied;
char text[50];
filetext=fopen("filetext.txt","r");
filecopied=fopen("filecopied.txt","w");
if ( (filetext==NULL) ||... |
Forum: DaniWeb Community Feedback 11 Days Ago |
| Replies: 90 Views: 4,706 Yup. I need the flyover to remind me that it means multiquote.
Just press the "quick reply" button, or the "reply to thread" button :)[/QUOTE]Ah, but that's defeatured... |
Forum: DaniWeb Community Feedback 11 Days Ago |
| Replies: 3 Views: 319 I believe your expectation used to be the default behavior. The new default was an "upgrade" a while back. The compromise you see is the result of some complainin'. (If I remember things correctly.) |
Forum: C++ 12 Days Ago |
| Replies: 3 Views: 155 http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12 ? |