|
I think tree structer is far more better than the bubble sort in actual work, if you are doing a actual work not homework. there is less moving when the tree is used.
|
|
|
|
|
Hello,
I'm writing this program for an academical assignment that is why i need to use the bubble sort algorithm, even though, from what i undersand, is not the most suitable solution.
I have tried to go on with my code but it's still not working and i'm getting more and more confused because i don't have really clear in my mind how to handle pointers...
Here is what i have done but i'm sure it's completely wrong
#include <stdio.h>
#include <string.h>
#define SIZE 30
int main()
{
char name[ SIZE ];
FILE *fpPtr;
if ( ( fpPtr = fopen( "sorted_file.txt", "r" ) ) == NULL ) {
printf( "File could not be opened\n" );
}
else {
printf( "%s\n", "Name" );
fscanf( fpPtr, "%s", name );
while( !feof( fpPtr ) ) {
printf( "%s\n", name );
fscanf( fpPtr, "%s", name );
}
fclose( fpPtr );
}
for ( pass = 1; pass < SIZE; pass++ ){
for ( counter = 0; counter < SIZE - 1; counter ++ ){
if ( *name [ counter ] > *name [ counter + 1 ] ) {
hold = *name[ counter ];
*name[ counter ] = *name[ counter + 1 ];
*name[ counter + 1 ] = hold;
}
}
}
return 0;
}
|
|
|
|
|
Please help:
Here is code I tried, but not working.
*/
char string[150];
char * dummy;
fscanf(f_ptr1,"%s\n",string); reading a line: 1,1,E1,0.13060,-0.40193,-0.90631
nl = int(strtok(string, seps)); // Get the first token
nd = int(strtok(string, seps)); // Get the second token
dummy = strtok(string, seps); // Get the third token
xx = atof(strtok(string, seps)); // Get the fouth token
yy = atof(strtok(string, seps)); // Get the fifth token
zz = atof(strtok(string, seps)); // Get the sixth token
Here nl, nd are integer, xx,yy,zz, are float.
Please point out how to make codes work. Thanks a lots
|
|
|
|
|
Two mistakes:
- You can't get an integer from a string by casting - use atol (that's like atof for integers)
- You only pass the string pointer the first time you call strtok for a string. The other times, pass a null pointer
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Could you fix the codes and post a working ones ?
That would be greatly appriaciated.
|
|
|
|
|
It'll help you more to fix it yourself.
Some hints:
- Replace the 'int' in the nl and nd casts by 'atol'
- A null pointer is zero. Replace the 'string' argument in all except the first strtok call. Look at the strtok documentation[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You are a good coach.
Thanks tons. It works now. Do you see any improvement from the following code. Please point out to me.
Thanks alots
char string[80]=" ";
char * dummy;
char seps[] = ",";
for (i=0;i<nhole;i++)
{
// fscanf(f_ptr1,"%i,%i,%i,%s,%f,%f,%f\n",&kdum[i],&nlinks[i],&ndih[i],buffer,&cos_xx[i],&cos_yy[i],&cos_zz[i]);
fscanf(f_ptr1,"%s\n",string);
kdum[i] = atol(strtok(string, seps));
nlinks[i] = atol(strtok(NULL, seps));
ndih[i] = atol(strtok(NULL, seps));
dummy = strtok(NULL, seps);
cos_xx[i] = atof(strtok(NULL, seps));
cos_yy[i] = atof(strtok(NULL, seps));
cos_zz[i] = atof(strtok(NULL, seps));
}
//
|
|
|
|
|
Looks OK to me
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
"atof" returns double. Do you have one returning to float ?
Thanks.
|
|
|
|
|
No. Doesn't really matter - double will get trruncated into a float.
To be honest, you're better off using double, so long as 8 rather than 4 byte isn't an issue. double is the native format of your CPU, which means double operations are often quicker than float operations.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for clarify to me. I am learner for C++.
Thanks again.
|
|
|
|
|
Hi there guys!
now am doing a project in which I want to switch of up to 8 LED's simply by sending an sms to an Ericsson phone.
Here's what I intend:
The program will pick up a received sms from the phone which is connected to the serial port (RS232) and depending on the message, either switch on of off one of the LED's connected to the computer at the Parallel port.
I have done abit on programming the parallel port in vc++
Can the same program therefore control the serial port and how can I do it?
Need help!
Regards
|
|
|
|
|
Reading from and writing to the serial port is done the same way as in the parallel port case: using ::ReadFile() and ::WriteFile() .
So if you've done some parallel port programming, what seems to be the problem in the serial port case?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
I have a old project, that is in VC++ and crystal reports 7.0.
After converting the c++ code in vs2008 (after removing some conversion error) will it work in vs2008.
Means is crystal reports 7.0 is supported in vs2008?
Please guide me.
Pankaj Gupta
(Take it easy)
|
|
|
|
|
Why not write a small program in VS 2008 and try it out with crystal reports?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
In vs2008, the crystal report higher version is already incorparted with that it is working fine.
Pankaj Gupta
(Take it easy)
|
|
|
|
|
One might think that you haven't answered my question. If you want VS 2008 to see if it works with a particular version of crystal reports,
1. Why not check it with *that* version?
2. Why are you particular in using an old version?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hi, I have a problem about how to convert the vrml files into openGL and display in an MFC application. Please, Anyone can help me?
|
|
|
|
|
There are two sites that can be very useful when doing something like this: Google[^] and CodeProject[^]. Have you heard of either of them?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the suggestion, but take several days looking for. If I write here is to get help from someone, because I have doubts that have not been resolved. Maybe I should ask before you assume.
|
|
|
|
|
The CodeProject link I sent you was a link to an article[^] describing a VRML viewer using OpenGL and MFC.
If you have specific issues with the technologies you talked about, why not mention them? If you just say "Can anyone help me" without really talking about your problem, then I and most every other poster will presume you're looking for answers without putting in any effort, so you'll get the response I gave you.
Be specific - then we can more likely help you.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
OK, my problem is about libraries and their use in windows. Something specific that can not find.
With regard to The CodeProject link seems not to be usable in all VRML files and this is very problematic for me.
|
|
|
|
|
Pompeyo wrote: OK, my problem is about libraries and their use in windows
Still not terribly specific...are you having trouble building your software because of some third party library?
Pompeyo wrote: With regard to The CodeProject link seems not to be usable in all VRML files
How about this one[^]? It claims to have a complete VRML parser (doesn't mean it displays all of VRML, I'll grant).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: Still not terribly specific...are you having trouble building your software because of some third party library?
Good, seeking advice on picking which librarie, because I can not find a clear path for where to walk.
Stuart Dootson wrote: How about this one[^]? It claims to have a complete VRML parser (doesn't mean it displays all of VRML, I'll grant).
Similar to above, can not show basic forms.
|
|
|
|
|
Hello All,
Im searching for a few hours how can i get HWND os desired window(ex. EXCEL)
I want to start appliction from my c++ program.
For starting it i use:
CreateProcess( NULL , pszLogfile , NULL , NULL , FALSE , CREATE_NEW_PROCESS_GROUP|NORMAL_PRIORITY_CLASS ,NULL,NULL, &si , &pi ) ;
But I must check if is already started and if it is yust bring it to foreground :
ShowWindow(MyhWnd,SW_SHOWNORMAL);
SetForegroundWindow(MyhWnd);
I need HWND to do this I can get HANDLE but i can not used it instead HWND???
I tryed with FindWindow but id dose not find all HWND's.
Is there any way to get HWND from exe, (ex. for excel from excel.exe,vncviewer.exe...)
I ll be happy for any help and Im thanking You in advace.
|
|
|
|
|