|
Since Linq was designed as a C# language feature, many uses of it don't include a C++/CLI example in my experience. I have used it from C++/CLI however but it takes a bit of tinkering. Here's one example from a simple utility I had where I used ToList() which is probably similar to ToDictionary().
List<String^>^ files = Linq::Enumerable::ToList<String^>(Directory::EnumerateFiles(dataDir, "*.dat"));
int count = Linq::Enumerable::Count(files);
I've not yet encountered something managed which just could not be done from C++/CLI. But, the C# syntax is often more direct.
|
|
|
|
|
i've a code. the code cant be compile. what i can to do this problem. what the step would be i step?
|
|
|
|
|
Read the error message. It contains the source file name and line number where the error occured. If not, it is probably a linker error.
Try to understand the error message. Read the documentation for the error message. Search the net for the error message.
Compiler error: Inspect the reported line and the previous ones (some errors are sourced by invalid statements in previous lines but detected later).
If you have multiple error messages, start with the first (subsequent errors may be sourced by previous ones).
If you still not get it solved, ask here (or in other forums) providing the complete error message and related code. If necessary add additional information (e.g. about variables used by the code, used compiler, platform).
|
|
|
|
|
I m using VC++ VS2008 compact edition. I hv problem that
when I m using "
GetUsbDriveLetter(CString) at compiled time error occurred not defined because it is in winbase.h sdk function. And CE7 hv different sdk therefore it occurred. please suggest me how to get USB letter in CE7
YogeshJadhav
|
|
|
|
|
There is no GetUsbDriveLetter function in any Windows API (I don't know that function and a quick search did not found it too). Especially it can't be defined in winbase.h because that declares only plain Win32 functions which does not know the CString type.
Also, please don't post the same question at multiple places. I suggest that you delete the duplicate in the ATL / WTL / STL Discussion Boards[^]. Even this forum is not the correct one. The C / C++ / MFC board would have been a better choice.
|
|
|
|
|
sorry sir but how to delete it
|
|
|
|
|
It's too late now because there is a reply.
That is the problem with cross posts:
You have multiple threads on the same topic with replies from different users.
|
|
|
|
|
actual error is
Error 294 error C3861: 'GetLogicalDriveStrings': identifier not found
|
|
|
|
|
And I have already answered that question.
|
|
|
|
|
|
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.
|
|
|
|