|
I don't know much about Windows CE but AFAIK that does not use drive letters. It mounts drives like Unix at the root folder. A quick search indicates that you can might use the StoreManager (FindFirstStore / FindNextStore ) to enumerate drives.
|
|
|
|
|
how to make a program in singly linked list that can divided two part,where the first linked list contain Element with an odd number element value and the second is even number.
thank you
|
|
|
|
|
|
thank you for your reply..
this is the code in klien.c
#include <stdio.h>
#include <stdlib.h>
#include "list.h"
int main(int argc, char *argv[]){
List L = NULL;
Position P = NULL;
L = Construct(L);
P = Header(L);
int i, n, *element;
printf("Entri element: ");
scanf("%d", &n);
element = (int*)malloc(n*sizeof(int));
for(i =0; i<n; i++){
printf("Entri element[%d]: ", i);
scanf("%d", &element[i]);
Insert(element[i], L, P);
P = Advance(P);
}
printf("\n");
getLargestElement(L);
return 0;
}
this is the code in list.h
typedef int ElementType;
#ifndef _List_H
#define _List_H
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;
List Construct(List L);
Position Header(List L);
void Insert(ElementType X, List L, Position P);
int IsLast(Position P, List L);
Position Advance(Position P);
Position getLargestElement(List L);
int IsEmpty(List L);
#endif
and the last in list.c
#include <stdio.h>
#include <stdlib.h>
#include "list.h"
struct Node{
ElementType Element;
Position Next;
};
List Construct(List L){
L = malloc(sizeof(struct Node));
if(L==NULL)
printf("Memori Kosong dan Tidak Dapat Dialokasi");
L->Next = NULL;
return L;
}
Position Header(List L){
return L;
}
void Insert(ElementType X, List L, Position P){
Position TmpCell = NULL;
TmpCell = malloc(sizeof(struct Node));
if(TmpCell == NULL) printf("Memori Kosong dan Tidak Dapat Dialokasi");
TmpCell->Element = X;
TmpCell->Next = P->Next;
P->Next = TmpCell;
}
int IsLast(Position P, List L){
return P->Next == NULL;
}
Position Advance(Position P){
return P->Next;
}
int IsEmpty(List L){
return L->Next == NULL;
}
Position getLargestElement (List L){
ElementType Largest;
Position P;
if(!IsEmpty(L)){
P = L->Next;
Largest = P->Element;
while(!IsLast(P, L)){
P = P->Next;
if(P->Element > Largest){
Largest = P->Element;
}
}
printf("element terbesar adalah: %d\n",Largest);
}
else{
printf("tidak ada ");
}
return 0;
}
and my problem is i dont know how to make a splitlist function in my email before..
thank you
|
|
|
|
|
You just need two new lists, one for odd numbers and one for even. Then for each value in the original list you add it to the appropriate new list.
|
|
|
|
|
thanks for your reply,but can you help me to show the sample code please..
|
|
|
|
|
You already have the code for a linked list, so all you need to do is to create two more the same as that one, and copy the elements from the original into the new ones. Odd elements to one list and even to the other.
|
|
|
|
|
Big thanks for your reply..
|
|
|
|
|
I was praciticing an exercise in the book called C How to program by deitel. In which a question is there about cryptography.
Following is the question (Also notice to the phrase mentioned in BOLD letters).
Quote: (Enforcing Privacy with Cryptography) The explosive growth of Internet communications and data storage on Internet-connected computers has greatly increased privacy concerns. The field of cryptography is concerned with coding data to make it difficult (and hopefully—with the most advanced schemes—impossible) for unauthorized users to read. In this exercise you’ll investigate a simple scheme for encrypting and decrypting data. A company that wants to send data over the Internet has asked you to write a program that will encrypt it so that it may be transmitted more securely. All the data is transmitted as four-digit integers. Your application should read a four-digit integer entered by the user and encrypt it as follows: Replace each digit with the result of adding 7 to the digit and getting the remainder after dividing the new value by 10. Then swap the first digit with the third, and swap the second digit with the fourth. Then print the encrypted integer. Write a separate application that inputs an encrypted four-digit integer and decrypts it (by reversing the encryption scheme) to form the original number. [Optional reading project: Research “public key cryptography” in general and the PGP (Pretty Good Privacy) specific public key scheme. You may also want to investigate the RSA scheme, which is widely used in industrial-strength applications.]
Following is the code block I've written for Encryption Scheme.
#include<stdio.h>
void main(){
int iFirst;
int iSecond;
int iThird;
int iFourth;
int iTemp;
printf("\nEnter four digits (with a space in between): ");
scanf("%d %d %d %d", &iFirst, &iSecond, &iThird, &iFourth);
iFirst = iFirst + 7;
iSecond = iSecond + 7;
iThird = iThird + 7;
iFourth = iFourth + 7;
iFirst = iFirst % 10;
iSecond = iSecond % 10;
iThird = iThird % 10;
iFourth = iFourth % 10;
iTemp = iFirst;
iFirst = iThird;
iThird = iTemp;
iTemp = iSecond;
iSecond = iFourth;
iFourth = iTemp;
printf("\nEncrypted Data - %d%d%d%d", iFirst, iSecond, iThird, iFourth);
}
Output -
Quote: Enter four digits (with a space in between): 1 2 3 4
1 2 3 4
Encrypted Data - 0189
and Decryption Scheme -
#include<stdio.h>
void main(){
int iFirst;
int iSecond;
int iThird;
int iFourth;
int iTemp;
printf("\nEnter encrypted four digits (with a space in between): ");
scanf("%d %d %d %d", &iFirst, &iSecond, &iThird, &iFourth);
iTemp = iFirst;
iFirst = iThird;
iThird = iTemp;
iTemp = iSecond;
iSecond = iFourth;
iFourth = iTemp;
iFirst = iFirst % 10;
iSecond = iSecond % 10;
iThird = iThird % 10;
iFourth = iFourth % 10;
iFirst = iFirst + 7;
iSecond = iSecond + 7;
iThird = iThird + 7;
iFourth = iFourth + 7;
printf("\nDecrypted Data - %d%d%d%d", iFirst, iSecond, iThird, iFourth);
}
Output-
Quote: Enter encrypted four digits (with a space in between) 1 8 9
0 1 8 9
Decrypted Data - 151678
Above programs should be working like this - if Encryption programs output for input 1234 is 0189 then Decryption program's output for input0189 should be 1234 but its not happening not sure why.
Can anyone help on this?
|
|
|
|
|
To perform a reverse operation you have to not only reverse the operation direction but also the operations itself.
So you have to:
iFirst -= 7;
if (iFirst < 0)
iFirst += 10;
[EDIT]
Adding 7 followed by modulo 10 must be treated as single operation here (the modulo just ensures that the result is a single digit).
Similar for the reverse operation: Subtract 7 and ensure that the result is a positive single digit number.
[/EDIT]
|
|
|
|
|
Cool... It worked so well Thank you so much for help.
|
|
|
|
|
|
|
the decryption is wrong
1.encryption
#include<stdio.h>
void main(){
int i[4];
printf("\nEnter four digits (with a space in between): ");
for(int j=0;j<4;j++)
{
scanf("%d", &i[j]);
}
i[1] = i[1]+7;
i[2] = i[2]+7;
i[3] = i[3]+7;
i[0] = i[0]+7;
i[1] = i[1]%10;
i[2] = i[2]%10;
i[3] = i[3]%10;
i[0] = i[0]%10;
int k=0;
k = i[0];
i[0] = i[2];
i[2] = k;
k = i[1];
i[1] = i[3];
i[3] = k;
printf("\nEncrypted Data - %d%d%d%d", i[0], i[1], i[2], i[3]);
}
2.decryption
#include<stdio.h>
void main(){
int i[4];
printf("\nEnter four digits (with a space in between): ");
for(int j=0;j<4;j++)
{
scanf("%d", &i[j]);
}
int k=0;
k = i[0];
i[0] = i[2];
i[2] = k;
k = i[1];
i[1] = i[3];
i[3] = k;
for(int j=0;j<4;j++)
{
if(i[j]<7)
{
i[j]=i[j]+3;
}
else
{
i[j]=i[j]-7;
}
printf("%d",i[j]);
}
}
|
|
|
|
|
I am trying to print some data from my application.It is printing the data but the page is not coming out of the printer.Please help me on this.
<pre>HANDLE hPrinter;
DOC_INFO_1 DocInfo;
DWORD dwJob;
DWORD dwBytesWritten;
char *lpData="welcome to delopt";
char *szPrinterName="CUSTOM TG2460-H";
if( ! OpenPrinter( szPrinterName, &hPrinter, NULL ) )
return ;
DocInfo.pDocName = "My Document";
DocInfo.pOutputFile = NULL;
DocInfo.pDatatype = "RAW";
if( (dwJob = StartDocPrinter( hPrinter, 1, (unsigned char*)(LPSTR)&DocInfo )) == 0 )
{
ClosePrinter( hPrinter );
return;
}
if( ! StartPagePrinter( hPrinter ) )
{
EndDocPrinter( hPrinter );
ClosePrinter( hPrinter );
return;
}
int dwCount=19;
if( !WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten ) )
{
EndPagePrinter( hPrinter );
EndDocPrinter( hPrinter );
ClosePrinter( hPrinter );
return;
}
.
if( ! EndPagePrinter( hPrinter ) )
{
EndDocPrinter( hPrinter );
ClosePrinter( hPrinter );
return;
}
if( ! EndDocPrinter( hPrinter ) )
{
ClosePrinter( hPrinter );
return;
}
if( dwBytesWritten != dwCount )
return;
ClosePrinter( hPrinter );
return;</pre>
this is for dialog based application.
|
|
|
|
|
|
I have commented that but still the same.
i will explain it once again.
see when i am executing the come then after clicking on the button it is printing the message but print is not coming out of the printer. It is printing the message on the paper but the paper is not coming out of printer it is just printing the text and stopping at that particular point only.
|
|
|
|
|
You need to use your debugger to step through the code and check exactly which of the spooler functions get called, and in which order.
|
|
|
|
|
there is only one spooler function is there in the code right n if i am wrong please explain it as for the first time i am doing that i dnt have much idea about that.
|
|
|
|
|
Sorry, I have not used the spooler functions before so cannot offer any further suggestions. You could try a Google search to see if anyone has written a tutorial on the subject.
|
|
|
|
|
|
I just tried this on my local printer using TEXT mode rather than RAW and it works correctly.
|
|
|
|
|
Thank you its working just one more help can u tell me how i can format the page which i want to print.for example:
name : XYZ
age : 19
.
.
.
etc.
|
|
|
|
|
You need to put the newline characters at the end of each string thus:
"This is line 1\r\n"
"This is line 2\r\n"
etc.
However, you would get better results by doing proper GDI based printing where you can format your pages properly.
|
|
|
|
|
what i should do for formatting the page like font size,font type , print quality and how many character should be printed in that particular line.
|
|
|
|