You mean the same way that browsers understand the difference between the header and content?
http://www.rfc-editor.org/
Find the RFCs for HTTP and read.
You mean the same way that browsers understand the difference between the header and content?
http://www.rfc-editor.org/
Find the RFCs for HTTP and read.
OK, so what part of fgets() + sscanf() did you not understand?
> printf("Employee no. : ");
> scanf("%ld",&D.no);
Should be
printf("Employee no. : ");
fgets( temp, sizeof temp, stdin );
sscanf( temp, "%ld",&D[i].no);
temp is just a char array, I typically use BUFSIZ for it's size.
You're mixing scanf() with fgets().
scanf() leaves a \n almost all of the time, then fgets() does "mmm, yummy, a \n. I'm done here".
If you're going to use fgets(), use it for EVERYTHING, and then use sscanf() if you must.
Or one of many ideas on flushing the input stream which is NOT fflush(stdin).
Well where are you in the code are you when it starts to produce those messages?
It seems to me it's already going wrong by that time.
> char NOUN[5][6] ={"noun1","noun2","noun3","noun4","noun5"};
These go in exactly ONE .c file, and without all the #ifdef stuff.
> extern char NOUN[5][6];
These go in a header file, to be included in all the files which need to access NOUN.
> for ( int col = 0 ; col < store.size() ; col++ )
Limit this by the size of the maze, not the size of the line.
> for(int i=0;i<50;i++)
Consider
const int mazeWidth = 50;
and use that constant in all the relevant places.
How did you declare maze anyway?
> while (!file.eof())
Use
while ( getline(file, store) )
which reads a line, or exits the loop.
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1046476070&id=1043284351
> Any clues why?
Because you passed a POINTER to i.
The main() thread exits, the i variable goes out of scope and another thread is looking down the barrel of a segfault.
> also any general tips for writing good multi-threaded code are welcome.
Well the first step is to make sure that whatever parameter you pass has a lifetime which exceeds the thread creator.
Using dynamic memory, and then making the thread the owner of that memory is one way to achieve this.
This also solves the other problem of helping to ensure that only one thread has access to the memory passed into it.
Put a data access breakpoint on the address of argc, then wait for something to happen.
Splitting it up into several functions (say one to determine the sort key(s), and one to do the actual sorting) would be a start.
250+ line functions are hard to read / test / debug.
Please use code tags to post indented code.
#include<iostream>
#include<cstdio>
//#include<conio>
using std::cout;
using std::cin;
using std::endl;
int main(void)
{
//clrscr();
int a[10];
int s=3;
int i,j,temp;
cout<<"\t\t *SORTING OF THREE ElEMENTS * "<<endl<<endl;
for(i=0;i<s;i++)
{
cout<<"Enter the "<<i+1<<" Element: ";
cin>>a[i];
}
cout<<"\n\nBefore Sorting : \n\n";
for(i=0;i<s;i++)
cout<<a[i]<<" ";
for(i=0;i<s;i++)
for(j=0;j<(s-i);j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
cout<<"\n\nAfter Sorting : \n\n";
for(i=0;i<s;i++)
{
cout<<a[i]<<" ";
}
return 1;
}
> why must C++ be so difficult/strict with this?
Power comes with responsibility.
Scripting languages have expressive power in that you can just write your solution without any care about how it works underneath. But your "I'll just return an array" will entail a hell of a lot of work for the machine, which you just won't see. In a small program, you won't notice, but sooner or later you might think "this is running a bit slow".
C++ (and down through C and to ASM) confront you head on with the problem to make you realise that it isn't quite a free lunch, and you need to start thinking about exactly how it's implemented. Yes it's more work for you, but get it right and you'll see some pretty amazing performance results.
The C++ STL (vector as already mentioned, and a lot of other goodies) go a long way to insulating you from some of the very raw detail. But vanilla arrays in C++ are the same as arrays in C, so you really have to do all the work yourself.
> Give me a complete process to install it.
What?
More complete than the "complete" instructions on the WINE homepage?
http://www.winehq.org/
And if you're still stuck, they have FAQs and Forums and IRC channels and.......
I wonder who makes macintoshessssss.......
http://developer.apple.com/
Nah, can't be that obvious, can it?
I see ArkM has already posted the actual answer, so trying to leave clues just isn't going to work.
Is this number the same as the previous number?
- yes - do something
- no - do something else
1 1 2 3 3 3 3 3
Mode is 3
Run length of 1's is 2
Run length of 2's is 1
Run length os 3's is
See?
Why did you sort it?
http://en.wikipedia.org/wiki/Mode_(statistics)
To make it easier to count identical values, because they're next to each other?
Because there is no defined relationship between the ++ and the three reads of the variable.
Your code is broken in both cases.
http://c-faq.com/expr/index.html
and in particular
http://c-faq.com/expr/seqpoints.html
As soon as you have undefined behaviour, then all bets are off.
Anything can happen, including what you imagine to be the "correct answer".
> hmmmm dude i was busy with some other issues.
Your choice - give up programming or give up something else.
You're not going to learn anything by dipping into programming for a couple of hours a month, so I'd say give up.
Otherwise you would have found a way to do something in the last fortnight, rather than just showing up here at the last minute hoping for salvation.
> Any one plz help me on this urgently?
You've had 13 days to play with the code ArkM posted, and now you're trying to make it into OUR problem?
http://www.catb.org/~esr/faqs/smart-questions.html#urgent
Ha ha ha ha ha *plonk*
I'd guess your code.
Get better information by posting your actual code.
Post a short example which doesn't seem to work.
Did you remember the
extern "C"
bit around anything which needs to be compatible with C ?
Nevermind - it doesn't have code tags, so I lost interest.
> sprintf(pos, "%05d", 1);
Only that you forgot to count the \0, and it's trashing something else.
Start with the basics.
Read some input, and print it right back out.
Then think about modifying it to detect a palindrome.
> awk '{print $rBytes / 100000}'END
How is that anything like what I posted?
Personally, I would just do awk '{print $2 / 1000000 }'
and stop worrying about just how good the maths is in the shell.
Also, awk has printf() as well, so you've got really good control over the format as well.
The first one is initialisation, the second one is assignment.
Arrays cannot be assigned in either C or C++.
You also need to get out of the "arrays are pointers" mode of thinking.
http://c-faq.com/aryptr/index.html
> is it true that A. calloc allocates memory in contiguous bytes, malloc does not ensure contiguous memory allocation?
No, it's false.
calloc is nothing more than malloc + memset to wipe the memory to all-bits-zero.
> i mean early intell CPUs could onley address (64K)
Only 64K in a single block.
If you wanted more, then you had to start messing about with segment registers
http://en.wikipedia.org/wiki/X86
> how can i use malloc or calloc for a two demontional arrays?
One (of several) ways
char **arr = malloc( rows * sizeof *arr );
for ( r = 0 ; r < rows ; r++ ) {
arr[r] = malloc( cols * sizeof *arr[r] );
}
Convert to a string using say sprintf(c) or stringstream(c++)
Then output the string as you know how to.
Start with
readData(cityArr, tempArr);
// getHighTemp(cityArr, tempArr);
// getLowTemp(cityArr, tempArr);
// calcAvgTemp(tempArr);
Does it crash?
How about
readData(cityArr, tempArr);
getHighTemp(cityArr, tempArr);
// getLowTemp(cityArr, tempArr);
// calcAvgTemp(tempArr);
Maybe this
readData(cityArr, tempArr);
getHighTemp(cityArr, tempArr);
getLowTemp(cityArr, tempArr);
// calcAvgTemp(tempArr);
Understand?
Or you could use a debugger, which would save all the edit the code, try it and repeat.
Any particular reason why we would want to look at that unindented mess?
You test x, and only change y
http://docs.sun.com/app/docs/doc/800-7895/6hos0aou4?a=view
Floats are approximations of an infinite number space mapped onto a finite machine. Mathematical results and computational results seldom agree. Any floating point result comes with an error margin.
> As I would hate to have to swap to VC++ just to solve this problem
If you count sweeping the problem under the carpet as a solution.
You might be printing zero, but does this?
double answer = a - ((2.00*(com/1000.00)) + b);
if ( answer == 0 ) {
cout << "Zero" << end;
} else {
cout << "NOT Zero" << end;
}
This is tricky stuff, as evidenced by this long drawn-out thread.
http://www.daniweb.com/forums/thread45388.html
> (Press Retry to debug the application)
Do this.
When the debugger starts, do something like
view->stack
That will tell you how the code got to that point.
Somewhere through the various stack levels will be your code. Click on the first one you recognise. It should open your source code. Examine really carefully all the parameters which are being passed. Chances are, one of them is NULL, and it shouldn't be.
The first error was not reading all the forum rules about using code tags.
> const char* article[]={"the", "a", "one", "some", "every", "any"}
Is (for the compiler)
const char* article[6]={"the", "a", "one", "some", "every", "any"}
You cannot write a function which will tell you the answer 6.
You can do this, which will give you 6 sizeof(article)/sizeof(article[0])
Which can be conveniently expressed as a macro #define ASIZE(x) (sizeof(x)/sizeof(x[0]))
You then write sentence = article[(rand()%ASIZE(article))]
So what's the problem?
Stopping when you see a "." ?
Reading a line?
Extracting words from a line?
Or just printing them in reverse?
Show us where you can get to yourself.
> ReadConsoleInput(stin, inputStat, 1, &NumRead);
How about
ReadConsoleInput(stin, inputStat, numEvents, &NumRead);
> delete inputStat;
How about
delete [ ] inputStat;
You should also check the console API calls for success/failure as well.
I'm confused.
Not all those lines contain "QuarkXP", but apparently, you passed the output of lsof through grep.
I think your estimation of C and C++'s imminent demise is overrated.
Nobody is going to be writing an entire OS / mobile phone / any other handheld consumer electronic device entirely in C# any time soon.
> lsof |grep QuarkXP|awk '{ print $9,$10,$11,$12 ]'>/tmp/output1
1. Copy the line you used, not something typed "as you remember it". The ] breaks it. I'm not sure your awk command to print a few fields is going to work, since the default field separator is whitespace, the result isn't going to be a meaningful filename.
Post an example output of lsof |grep QuarkXP
And in other news, reports are coming in from all over the web about the same thing happening elsewhere.
Experts agree that there is only one possible solution.
Well seeing as it took you 3 days to post some actual useful information about the problem, perhaps you could point us to an online manual for the compiler which you're having trouble reading.
Better yet, show us that you've tried to understand the manual by pasting some actual commands tried, and the results you got.