|
|
Hey,
I need a C code which builds the printer job queue. However, the printer job queue is built as a two level priority queue.
modified 22-May-14 3:55am.
|
|
|
|
|
Looks like a single linked list.
Here is a program for a single link list - Singly linked list[^]
You will need to modify the program slightly to cater to your requirement.
The given program only uses an integer variable.
Instead, you will need to make 2 checks on the userType and the pages .
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
|
Its probably because of an incorrect condition check.
Please post the code with the page check that you put in.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
|
Logic looks OK.
I guess you need to single step through the code using the debugger and find out the issue.
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
I tried but didn't find the problem. Do you have an idea?
|
|
|
|
|
Finded it, thanks for your help!
|
|
|
|
|
I want to use C++ to call javascript and get the return value , but i don't how to use C++ to call js,and i don't how to give those parameters to the javascript function.
What should i do?
thanks for everybody's help!!
modified 22-May-14 8:54am.
|
|
|
|
|
jingjing yuan wrote: how to use c + + for the Jason data You need to explain where this data comes from and exactly what you expect your C++ program to do with it.
|
|
|
|
|
writing a program for send a command to INMARSAT via USB-RS232 and wait for the response coming within 20 seconds if the response not come means again send the commands to USB-RS232?
Uma Maheswari N
|
|
|
|
|
You should check out the documentation (datasheets, application notes, etc...) of your microcontroller and study it (probably you are going to find available code
Also you may post on more specialized forums inr order to get better help.
Veni, vidi, vici.
|
|
|
|
|
I hope you are not really asking what I think you are asking on a public forum and that this is something on the public access portal.
If not I warn you the INMARSAT protocol is proprietary and has a non disclosure agreement signed by yourself or someone who you work for. Refer the questions back thru the proper channels please and all the details are quite clear in the technical specification if you can not understand the document go back thru proper channels.
In vino veritas
|
|
|
|
|
Hmmmm,
As someone who has worked with inmarsat hardware I would guess that this guy is simply asking about MODBUS response timeouts which isn't really proprietary information.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi everyone.
I wrote a function that should copy in a strings' array all the name of several files contained in a folder.
void get_filenames(char dir[]){
int i=0;
DIR *sd;
sd = opendir(dir);
struct dirent *dird;
printf("\nLa cartella %s contiene %d files.", dir, n_files);
seekdir(sd, 2);
for(i=0;i<n_files;i++){
dird=readdir(sd);
filenames[i]=dird->d_name;
printf("\n%s", filenames[i]);
}
closedir(sd);
}
When I call this function it seems to be alright, and the printf contained in the for cicle prints the names of files correctly... But if I try to print these names somewhere out of this function, I see that each string of filenames[] contains the last string printed in the get_filenames function, that is the last file in the folder.
I allocated filenames[] in another void function, this way:
...
filenames = malloc(n_files * sizeof(char));
for(i=0;i<n_files;i++){
filenames[i] = malloc(20 * sizeof(char));
}
...
|
|
|
|
|
The line
filenames = malloc(n_files * sizeof(char));
should be
filenames = malloc(n_files * sizeof(char *));
because you use it to allocate pointers.
You don't show the declaration of filenames in the sample, but I assume it's char **.
By the way, what happens if a file in the directory has a name longer than 19 characters?
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
I think you'll find that the line:
filenames[i]=dird->d_name; should actually be something like:
filenames[i]=strdup(dird->d_name);
You see, dird->d_name is a location in memory that the current file's name is copied to - _but_ this location doesn't change, only the contents of the text does. What your code does is set each of the filename[] elements to hold this location. In the next iteration of the loop, the text contained there changes, but the location doesn't. So you've got all elements of filename[] holding the same address of a string.
If, on the other-hand, you make a duplicate of the string in dird->d_name and then store _that_ location into filenames[], each element of filenames[] will point to a different location in memory - locations that contain the string you're after.
Note - you should also change your last code-block.
filenames = malloc(n_files * sizeof(char*) );
So,
1) filenames should be a char** (I expect you've got it setup to be a char* currently)
2) each element (a char*) should contain the address of the duplicated string
3) No need for the filenames[i] = malloc(20 * sizeof(char) ); code.
|
|
|
|
|
Thank you for the answer.
Of course I declared filenames as char**... But I didn't know really good how the d_name variable works, then I made some mistakes... Now it's all clearer!
|
|
|
|
|
You're welcome.
I'd hoped you had, though the way you used it gave me the impression it was only a char*
Glad to be of help.
|
|
|
|
|
I cannot find its implementation anywhere. MSDN is not much of a help.
|
|
|
|
|
The MSDN entry[^] includes a link to a sample implementation.
|
|
|
|
|
Hello
I'm create an IE addon that inject a style sheet to page.
CComBSTR scTagStyle = "STYLE";
IHTMLElement* elementStyle;
HRESULT hr = spHTMLDoc->createElement(scTagStyle, &elementStyle);
IHTMLDOMNode *domStyleNode;
hr = elementStyle->QueryInterface(IID_IHTMLDOMNode, (LPVOID*)&domStyleNode);
IHTMLStyleElement *IstyleElem;
hr = elementStyle->QueryInterface(IID_IHTMLStyleElement, (LPVOID*)&IstyleElem);
I dont know the way to set css_text to IHTMLStyleElement.
Please help me solve this problem.
Regards,
Son Dang
|
|
|
|
|
Hi,
I'm trying to create .zip files within a C# application with the LZMA SDK.
The code worked immediately, but I can't figure out how to produce a .zip output, and I must have plain .zip. The 7z GUI produces .zip files with no problem, so it must be possible with the SDK.
I thought sure that changing the "algorithm" property was the answer, but running tests with that property ranging from 0 to 8 produced no apparent change in the output. Windows Explorer (7) rejects all such efforts, while the 7z GUI opens the outputs, no matter what.
I've spent too much time perusing the C++ source code for the GUI. It's obvious that the author has a command of C++ that's an order of magnitude greater than mine.
In short, what property need I set to what to yield a .zip output?
Thank you.
John
|
|
|
|
|
Shouldn't you rather be looking for an answer here[^]?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|