Forum: C 3 Hours Ago |
| Replies: 3 Views: 41 Try printing the bytes in the buffer rather than printing the buffer as a string (especially when you are not treating buffer as a string). |
Forum: C 1 Day Ago |
| Replies: 5 Views: 107 Okay. That one too.
Is the thing on the left side of the-> operator a pointer? |
Forum: C 1 Day Ago |
| Replies: 5 Views: 107 |
Forum: C 1 Day Ago |
| Replies: 1 Views: 85 Expected input and output would be helpful. Providing a small snippet of a simple test, minimal but complete and compilable, would too.
"This code doesn't do what I want (and I'm not going to tell... |
Forum: C++ 2 Days Ago |
| Replies: 5 Views: 126 You seem to be using a lousy code editor and have "fancy quotes" instead of the plain variety. After that you'll get more syntax errors to clean up, like this
int calc_bonus(int sales){
You need to... |
Forum: C 2 Days Ago |
| Replies: 5 Views: 173 Use system-specific APIs and write a fair amount of character-handling code.
Or use simple standard library functions and reject unwanted input.
Which is it that you want? |
Forum: C 2 Days Ago |
| Replies: 11 Views: 220 *sigh*
Of course it is. ALL structures of the structures in the first example are populated at compile time. A particular one isn't "selected" in the if tree. |
Forum: C 2 Days Ago |
| Replies: 11 Views: 220 Your first example may not be working the way you think it is. The #include directive is like a copy-and-paste that happens at compile time. You can't do it at runtime. |
Forum: C++ 5 Days Ago |
| Replies: 11 Views: 258 That happens to be true for the garden variety PC of today, but it is not true as a generic statement. |
Forum: C++ 6 Days Ago |
| Replies: 6 Views: 249 #include <iostream>
#include <fstream>
#include <cstdlib>
int main()
{
std::ifstream file("reg.txt");
char text[80];
while ( file.getline(text, sizeof text) )
{ |
Forum: C 7 Days Ago |
| Replies: 2 Views: 166 http://c-faq.com/stdio/fupdate.html ? |
Forum: C 7 Days Ago |
| Replies: 3 Views: 206 Are any of the suggestions here usable?
http://c-faq.com/varargs/nargs.html |
Forum: C++ 8 Days Ago |
| Replies: 5 Views: 185 |
Forum: C++ 9 Days Ago |
| Replies: 5 Views: 243 http://groups.google.com/group/comp.lang.c/browse_thread/thread/2aaf5360b08c89a9/1000b1f7fb33ea53?ie=UTF-8&q=float+promoted+double+function+group%3Acomp.lang.c&pli=1 |
Forum: C++ 9 Days Ago |
| Replies: 1 Views: 146 for (int i=1;i<=8;i++)Don't you mean this?for (int i=0;i<8;i++) |
Forum: C 10 Days Ago |
| Replies: 6 Views: 252 struct amicable* record;
/* allocate array of pointers */
record->amicablePair=(int**)malloc(nrows*sizeof(int*));record needs to point to something before you dereference what it points... |
Forum: C 10 Days Ago |
| Replies: 2 Views: 145 getline is not standard C. |
Forum: C 10 Days Ago |
| Replies: 6 Views: 173 I prefer not to use strtok in parsing, and I found your code a little confusing. I might take a little bit different approach, something like this:
void xref(FILE * inf, FILE * outf)
{
struct... |
Forum: C 10 Days Ago |
| Replies: 6 Views: 173 Thanks for posting the input file.
I just did this for a quick "fix" at the str issue (I don't have your malloc update to the code, nor did I really want to use malloc):
char foo[100], *str =... |
Forum: C 10 Days Ago |
| Replies: 6 Views: 173 Unless you post your input file (or did I miss it?), I think we're all pretty limited to static analysis to try to help you out. That's rather tedious, so I wasn't going to wander very far into it,... |
Forum: C++ 11 Days Ago |
| Replies: 3 Views: 227 I think this thread hits on it:... |
Forum: C++ 11 Days Ago |
| Replies: 3 Views: 168 #include <iostream>
#include <cmath>
using namespace std;
int main()
{
cout << "RAND_MAX = " << RAND_MAX << "\n";
return 0;
} |
Forum: C++ 11 Days Ago |
| Replies: 3 Views: 227 I don't think you even want the array, but instead are after this?
inFile.open(file); |
Forum: C 11 Days Ago |
| Replies: 6 Views: 173 Are you planning to point to memory you can write to before you write to it?
char *str, *tmp;
char linein[81];
linenum = arrpos = 0;
while(fgets(linein, 80, inf) != NULL)
{
... |
Forum: C++ 11 Days Ago |
| Replies: 3 Views: 112 Match your prototypes with function signatures. |
Forum: DaniWeb Community Feedback 11 Days Ago |
| Replies: 16 Views: 915 |
Forum: C++ 11 Days Ago |
| Replies: 4 Views: 163 You can't pass an array by value ("the whole array"). When you "pass an array", you instead pass a pointer to the first element. What I believe you are doing is writing to a random memory location... |
Forum: C++ 11 Days Ago |
| Replies: 4 Views: 163 Do you know why you're trying to use an array of pointers to char instead of an array of char?
main(){
const int max_chars =100;
int length= 0;
char* letters[max_chars + 1];
... |
Forum: C 12 Days Ago |
| Replies: 6 Views: 176 Casting is misued a lot of the time. And I would argue that this would be a great example.
If the string itself is nonwritable, the cast silences the warning and passes this nonwritable string to... |
Forum: C 12 Days Ago |
| Replies: 6 Views: 176 Why not just turn off the warning? :icon_rolleyes: |
Forum: C 12 Days Ago |
| Replies: 6 Views: 176 Have the code mirror what you're doing:
char *VAR1(const char *VAR2)
Also, make sure you have enough space to write into.
[edit]If he wants the warning...
why would a solution be to silence... |
Forum: C++ 12 Days Ago |
| Replies: 2 Views: 148 Lose the semicolon:
#define CAPACITY 128;
[edit]Avoid expressions like this:
i=(i++)%CAPACITY
http://c-faq.com/expr/ieqiplusplus.html |
Forum: C++ 12 Days Ago |
| Replies: 3 Views: 273 Another way would be to write this as a function. If any character does not match, you can break the loop early and return a value indicating the "strings" do not match. If all characters do compare... |
Forum: C++ 12 Days Ago |
| Replies: 4 Views: 207 Another way of reading "7 times per line" is "output a newline every 7 times". You could do this with a separate counter (in the same loop though!) that counts to 7, outputs a newline and then is... |
Forum: C 13 Days Ago |
| Replies: 5 Views: 195 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 13 Days Ago |
| Replies: 3 Views: 176 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++ 14 Days Ago |
| Replies: 5 Views: 302 time is a reserved identifier. |
Forum: C++ 16 Days Ago |
| Replies: 5 Views: 268 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 16 Days Ago |
| Replies: 3 Views: 232 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++ 16 Days Ago |
| Replies: 2 Views: 187 How about a final else?
And don't use the comma here:
else if (numtick >100,000) |