15,884,908 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 3975629 (Top 66 by date)
Member 3975629
28-Aug-15 3:42am
View
Hi Sergey ,
I am trying as below .but I am getting an error CS0411: as follows. any idea ?
Here "TopicDetails" is a datacontract class which has string data members.
List<TopicDetails> topicDetails3;
TopicDetails[] arr = topicDetails3.ToArray();
int[] myInts = Array.ConvertAll(arr, int.Parse);
error CS0411: The type arguments for method 'System.Array.ConvertAll<tinput,toutput>(TInput[], System.Converter<tinput,toutput>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Member 3975629
28-Aug-15 1:58am
View
If I use topicDetails.ToArray(); I am getting the error:
Cannot implicitly convert type 'Data.Notif.TopicDetails[]' to 'string[]' .
I think it is because "TopicDetails" is of type data contract "Data.Notif.TopicDetails"
I am not sure how to resolve this error.
Could you please let us know how to resolve this error.
Member 3975629
28-Aug-15 1:21am
View
Hi Sergey ,
I have added more detail here. As you suggested List has ToArray method.
I am little confused here. Because in C# , I have the following code
subscriptionTopicList.Add(SubscriptionTopic.CreateSubscriptions<List<topicdetails>, string>(topicDetails, "VIEW"));
Now if I use topicDetails.ToArray(); will it convert this to an integer array which I can pass to C++/CLI
and then to native C++ code as const vector<int> &optList ??
Appreciate your help.
Thanks
Member 3975629
27-Aug-15 7:14am
View
I need to convert the to convert a List of data contracts to an integer array[].
from C# to an Integer array[] in C++/CLI and then to C++ .
I need to convert from C# , List of datacontract to C++ const integer vector &topicList via C++/CLI wrapper.
Could you please let me know how can I achieve this.
Appreciate your help on this.
//topicDetails is a data-contract
CreateSubscriptions<List<topicdetails>(topicDetails);
//Here TopicDetails is a class (data contract) as follows.
public class TopicDetails
{
protected object baseObjectType; //string
protected object topic; //string
public TopicDetails();
[DataMember]
public object BaseObjectType { get; set; }
[DataMember]
public object TopicID { get; set; }
public static TopicDetails CreateTopic<t, mt="">(IComparable<t> objectType, IComparable<mt> objectID);
}
http://www.codeproject.com/Questions/1022559/How-to-convert-a-List-of-DataContracts-to-an-to-an?arn=0
Member 3975629
27-Aug-15 5:29am
View
As you asked ,
I need to convert from C# , List of datacontract to C++ const integer vector &topicList via C++/CLI wrapper.
I need to pass List of data contract to C++/CLI and then to C++
I need to convert List of data contracts from C# to an integer array in C++ thru a wrapper classes. Please see the details in the below link. And please provide your suggestions on how to achieve this. Thanks..
http://www.codeproject.com/Questions/1022559/How-to-convert-a-List-of-DataContracts-to-an-to-an?arn=0
Member 3975629
27-Aug-15 4:44am
View
Basically I am not getting any idea on how to proceed. could you please suggest any ideas/suggestions on how to approach this.
Thanks.
Member 3975629
26-Aug-15 8:24am
View
Thank you. I will try this out
Member 3975629
26-Aug-15 8:24am
View
Thank you. I will try this out
Member 3975629
26-Aug-15 8:24am
View
Thank you. I will try this out
Member 3975629
14-Aug-15 3:26am
View
I tried and it worked with double quotation also now "@". Thanks a lot.
String^ targetLocation = "@" + "Hello".
Seems strange to me as well. now it is working with "@" . Thanks.
Member 3975629
14-Aug-15 3:25am
View
I just copied the code from your snippet and tried and it worked with double quotation also "@". Thanks a lot.
String^ targetLocation = "@" + "Hello".
Seems strange to me as well. now it is working with "@" . Thanks.
Member 3975629
14-Aug-15 3:02am
View
I tried as below and it worked with single quote. instead of double quotes in my dev environment.
String^ str1 = "OXF";
String^ str2 = '@'+ str1;
Member 3975629
14-Aug-15 3:02am
View
I tried as below and it worked with single quote. instead of double quotes in my dev environment.
String^ str1 = "OXF";
String^ str2 = '@'+ str1;
Member 3975629
14-Aug-15 2:22am
View
My problem is , I am not able to concatenate "@" symbol to another C++/CLI string.
Any ideas on how to concatenate "@" to a C++/CLI string (i.e) String^ sample="Hello";
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
24-Jul-15 5:56am
View
I am getting the below line in the debugger when break-all (pause) the execution. " Cannot evaluate expression because a native frame is on top of the call stack" . some times it is working and sometimes it is NOT working. my code base consists of UnManaged C++ code ,Managed C++ code and C# code.
Member 3975629
22-Jul-15 1:38am
View
Actually our application is a WCF service cum client. We need to run one instance of our application which acts as server in one PC and another instance of our application which acts as client in another PC. We can not run client and server on the same PC.Hence debugging is getting difficult.Could you please let me know if there are any other ways that we can debug and find out the problem in this case. Thanks,Sudhakar
Member 3975629
21-Jul-15 9:17am
View
I have increased the sendTimeout="00:59:00" to almost 1 hour. still it is hanging and give the above time out error. Could you please let me know how to resolve this or any tips for debugging.? Thanks,Sudhakar
Member 3975629
20-Jul-15 7:48am
View
I checked the Event logs in the target PC. it is as follows. can we infer anything from this.
Message : The request channel timed out while waiting for a reply after 00:00:59.9989999. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
Source : AVEVA.GlobalWcf.ServiceClient
Member 3975629
15-May-15 2:47am
View
Here is my scenario : i am copying the data from dc to new data contract as below. after copying , when i am executing the createsubscriptions method i am getting the above mentioned error. i have given the details of data contract and error in the original question. please refer to that as well.
Method1(SubscriptionDataContracts dc)
{
SubscriptionDataContract subscriptionDataContract = new SubscriptionDataContract();
List<subscriptiontopicinfo> topicsInfo = dc.TopicList;
List<subscriptiontopic> newTopicsList = new List<subscriptiontopic>();
subscriptionDataContract.ExtensionData = dc.ExtensionData;
subscriptionDataContract.UserID = dc.UserID;
for (int i = 0; i < topicsInfo.Count; i++)
{
SubscriptionTopic topic = new SubscriptionTopic();
topic.DBHandle = topicsInfo[i].DBHandle;
topic.Topic = topicsInfo[i].Topic;
topic.Target = topicsInfo[i].Target;
newTopicsList.Add(topic);
}
subscriptionDataContract.TopicList = newTopicsList;
CreateSubscriptions(subscriptionDataContract); //getting teh above mentioned error here
}
Member 3975629
14-May-15 8:23am
View
Hi ,
I have data contract as follows. It has knownType attribute to most of them. but still i am getting the above mentioned error while passing this data contract to another method. Please let me know where exactly i need to add the knowntype attribute. I am really in confusion in finding out where exaclty is the problem ?
Appreciate your help.
[DataContract(Name = "TopicDetailsInfo", Namespace = "http://CName.GlobalService")]
[Serializable]
public class TopicDetailsInfo
{
protected object topic;
protected object baseObjectType;
[DataMember]
public object BaseObjectType
{
get
{
return baseObjectType;
}
set
{
baseObjectType = value;
}
}
[DataMember]
public object TopicID
{
get
{
return topic;
}
set
{
topic = value;
}
}
static public TopicDetailsInfo CreateTopic<t, mt="">(IComparable<t> objectType, IComparable<mt> objectID)
{
var topicDetails = new TopicDetailsInfo();
topicDetails.BaseObjectType = objectType;
topicDetails.TopicID = objectID;
return topicDetails;
}
}
[DataContract(Name = "SubscriptionTopicInfo", Namespace = "http://CName.GlobalService")]
[KnownType(typeof(List<topicdetailsinfo>))]
[Serializable]
public class SubscriptionTopicInfo
{
private object topic;
private object target;
private object creator;
[DataMember]
public object Topic
{
get
{
return topic;
}
set
{
topic = value;
}
}
[DataMember]
public object Target
{
get
{
return target;
}
set
{
target = value;
}
}
[DataMember]
public object DBHandle
{
get
{
return creator;
}
set
{
creator = value;
}
}
static public SubscriptionTopicInfo CreateSubscriptions<t, mt,="" nt="">(IList<topicdetailsinfo> topic, IComparable<mt> target, IComparable<nt> handle)
{
var subscriptionTopic = new SubscriptionTopicInfo();
subscriptionTopic.Target = target;
subscriptionTopic.Topic = topic;
subscriptionTopic.DBHandle = handle;
return subscriptionTopic;
}
}
[DataContract(Name = "SubscriptionData", Namespace = "http://CName.GlobalService")]
[KnownType(typeof(List<subscriptiontopicinfo>))]
[Serializable]
public class SubscriptionDataContracts : IExtensibleDataObject
{
private ExtensionDataObject extensionDataObjectValue;
[DataMember]
public string UserID
{
get;
set;
}
[DataMember]
public string ProjectID
{
get;
set;
}
[DataMember]
public string FromDiscipline
{
get;
set;
}
[DataMember]
public string ModuleID
{
get;
set;
}
[DataMember]
public string SessionID
{
get;
set;
}
[DataMember]
public List<subscriptiontopicinfo> TopicList
{
get;
set;
}
public ExtensionDataObject ExtensionData
{
get
{
return extensionDataObjectValue;
}
set
{
Member 3975629
29-Apr-15 3:00am
View
In short , I need to convert the attached C# datacontract to native C++ code.
In the attached C# data contract , i have data types like "List<datacontacts>" and "object" .
I would like to know how we can convert the above data contracts,list of data contracts ,object datatypes to native C++ datatypes like structures etc..
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
29-Apr-15 3:00am
View
In short , I need to convert the attached C# datacontract to native C++ code.
In the attached C# data contract , i have data types like "List<datacontacts>" and "object" .
I would like to know how we can convert the above data contracts,list of data contracts ,object datatypes to native C++ datatypes like structures etc..
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
28-Apr-15 3:09am
View
Thanks for your idea.
Currently my requirement is I need to pass a "list of data contracts" and a C# data type "object" to native C++ .
And then I need to convert them from native C++ to Managed C++.
Here we are facing some problems while we are converting C# data types like “object” and “List of datacontracts” from subscription data contract
to Native C++ structures and then converting to Managed C++ data types.
we have infrastructure/idea for converting normal data contract and normal data types like (string,int) to C strutures for converting to Native C++ and then we can Marshall them to Manged C++ as follows.
wsdc->UserID = Marshal::PtrToStringAnsi((IntPtr) (char *) sdc.UserID);
but we do not know how to convert the list of data contracts to C Structures and data type like "object" to native C++ and then to Manged C++.
Please let me know any ideas /suggestions on this.Please take a look at the data contract i attached above with this question.
Thanks,
Sudhakar
Member 3975629
27-Apr-15 8:08am
View
But still , in some of our projects ,we are marshalling (converting to Managed )C# data types to C++/CLI as follows:
wsdc->UserID = Marshal::PtrToStringAnsi((IntPtr) (char *) sdc.UserID);
Now i need to do the same for C# data types such as object and List of datacontracts.
Member 3975629
24-Apr-15 5:10am
View
Hi ,
Sorry for the confusion. My requirement is: I have a data contract as follows.it has another 2 data contracts inside it. which contains the values as objects,list etc...
Now i need to call a native C++ method from C# and pass this datacontract to the native c++. here my question is how can i manage the the passing of the below data contract to native C++ method .How to handle this datacontract inside C++ ??
I would like to have the method some thing like this:
EXPORT_VOID sendSubscriptions(handle_t binding_h, SubscriptionDataContract dc );
My Datacontract(s)-nested data contracts are as below:
I think i can use struct inside C++ , which is equivalent to data contract in C#.
but how to handle data members like this in C++ : object BaseObjectType
[DataContract(Name = "TopicDetails")]
public class TopicDetails
{
protected object topic;
protected object baseObjectType;
[DataMember]
public object BaseObjectType
{
get
{
return baseObjectType;
}
set
{
baseObjectType = value;
}
}
[DataMember]
public object TopicID
{
get
{
return topic;
}
set
{
topic = value;
}
}
static public TopicDetails CreateTopic<t, mt="">(IComparable<t> objectType, IComparable<mt> objectID)
{
var topicDetails = new TopicDetails();
topicDetails.BaseObjectType = objectType;
topicDetails.TopicID = objectID;
return topicDetails;
}
}
[DataContract(Name = "SubscriptionTopic")]
[KnownType(typeof(List<topicdetails>))]
public class SubscriptionTopic
{
private object topic;
private object target;
private object creator;
[DataMember]
public object Topic
{
get
{
return topic;
}
set
{
topic = value;
}
}
[DataMember]
public object Target
{
get
{
return target;
}
set
{
target = value;
}
}
[DataMember]
public object DBHandle
{
get
{
return creator;
}
set
{
creator = value;
}
}
static public SubscriptionTopic CreateSubscriptions<t, mt,="" nt="">(IList<topicdetails> topic, IComparable<mt> target, IComparable<nt> handle)
{
var subscriptionTopic = new SubscriptionTopic();
subscriptionTopic.Target = target;
subscriptionTopic.Topic = topic;
subscriptionTopic.DBHandle = handle;
return subscriptionTopic;
}
}
[DataContract(Name = "SubscriptionData")]
[KnownType(typeof(List<subscriptiontopic>))]
public class SubscriptionDataContracts : IExtensibleDataObject
{
private ExtensionDataObject extensionDataObjectValue;
[DataMember]
public string UserID
{
get;
set;
}
[DataMember]
public string ProjectID
{
get;
set;
}
[DataMember]
public string FromDiscipline
{
get;
set;
}
[DataMember]
public string ModuleID
{
get;
set;
}
[DataMember]
public string SessionID
{
get;
set;
}
[DataMember]
public List<subscriptiontopic> TopicList
{
Member 3975629
24-Apr-15 5:05am
View
Hi ,
Sorry for the confusion. My requirement is: I have a data contract as follows.it has another 2 data contracts inside it. which contains the values as objects,list etc...
Now i need to call a native C++ method from C# and pass this datacontract to the native c++. here my question is how can i manage the the passing of the below data contract to native C++ method .How to handle this datacontract inside C++ ??
I would like to have the method some thing like this:
EXPORT_VOID sendSubscriptions(handle_t binding_h, SubscriptionDataContract dc );
My Datacontract(s)-nested data contracts are as below:
I think i can use struct inside C++ , which is equivalent to data contract in C#.
but how to handle data members like this in C++ : object BaseObjectType
[DataContract(Name = "TopicDetails")]
public class TopicDetails
{
protected object topic;
protected object baseObjectType;
[DataMember]
public object BaseObjectType
{
get
{
return baseObjectType;
}
set
{
baseObjectType = value;
}
}
[DataMember]
public object TopicID
{
get
{
return topic;
}
set
{
topic = value;
}
}
static public TopicDetails CreateTopic<t, mt="">(IComparable<t> objectType, IComparable<mt> objectID)
{
var topicDetails = new TopicDetails();
topicDetails.BaseObjectType = objectType;
topicDetails.TopicID = objectID;
return topicDetails;
}
}
[DataContract(Name = "SubscriptionTopic")]
[KnownType(typeof(List<topicdetails>))]
public class SubscriptionTopic
{
private object topic;
private object target;
private object creator;
[DataMember]
public object Topic
{
get
{
return topic;
}
set
{
topic = value;
}
}
[DataMember]
public object Target
{
get
{
return target;
}
set
{
target = value;
}
}
[DataMember]
public object DBHandle
{
get
{
return creator;
}
set
{
creator = value;
}
}
static public SubscriptionTopic CreateSubscriptions<t, mt,="" nt="">(IList<topicdetails> topic, IComparable<mt> target, IComparable<nt> handle)
{
var subscriptionTopic = new SubscriptionTopic();
subscriptionTopic.Target = target;
subscriptionTopic.Topic = topic;
subscriptionTopic.DBHandle = handle;
return subscriptionTopic;
}
}
[DataContract(Name = "SubscriptionData")]
[KnownType(typeof(List<subscriptiontopic>))]
public class SubscriptionDataContracts : IExtensibleDataObject
{
private ExtensionDataObject extensionDataObjectValue;
[DataMember]
public string UserID
{
get;
set;
}
[DataMember]
public string ProjectID
{
get;
set;
}
[DataMember]
public string FromDiscipline
{
get;
set;
}
[DataMember]
public string ModuleID
{
get;
set;
}
[DataMember]
public string SessionID
{
get;
set;
}
[DataMember]
public List<subscriptiontopic> TopicList
Member 3975629
23-Apr-15 7:45am
View
I have a data contract and it has another data contract inside it as follows. My intention is i need to pass this data contract from C# to a managed C++ application.
I think we can handle datacontract as a structure in managed C++. but what if the data contract contains objects as elements as per below example ? How to handle this scenario ?
[DataContract(Name = "SubscriptionData")]
public class SubscriptionDataContract:IExtensibleDataObject
{
private ExtensionDataObject extensionDataObjectValue;
[DataMember]
public string UserID
{
get;
set;
}
[DataMember]
public List<subscriptiontopic> TopicList
{
get;
set;
}
public ExtensionDataObject ExtensionData
{
get
{
return extensionDataObjectValue;
}
set
{
extensionDataObjectValue = value;
}
}
}
[DataContract(Name = "SubscriptionTopic")]
public class SubscriptionTopic
{
public SubscriptionTopic();
[DataMember]
public object Handle { get; set; }
[DataMember]
public object Target { get; set; }
[DataMember]
public object Topic { get; set; }
public static SubscriptionTopic CreateSubscriptions<t, mt,="" nt="">(IList<topicdetails> topic, IComparable<mt> target, IComparable<nt> handle);
}
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
23-Apr-15 1:45am
View
in C# application, i have some code like this
SubscriptionDataContract subscriptionData = null;
subscriptionData = new SubscriptionDataContract();
From C# code application , I need to call the below method in Managed C++ (C++/CLI)
in which i want to pass the above data contact.
ClientSideWrapper.ClientInterface iClient = new ClientSideWrapper.ClientInterface();
iClient.sendMessage(handle,subscriptionData);
I need to create a method in Managed C++ (C++/CLI) , so that i can pass that datacontract (details) from C# to Managed C++ code and do the required processing.
But it seems Managed C++ will not take datacontract as parameter , as i am getting the below error:
with this function in Manged C++ .
EXPORT_VOID sendMessage(handle_t binding,DataContracts::NotificationDataContract^ dc);
error C3395: 'sendMessage' : __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention
Please let me know how to handle this scenario.
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
23-Apr-15 1:44am
View
in C# application, i have some code like this
SubscriptionDataContract subscriptionData = null;
subscriptionData = new SubscriptionDataContract();
From C# code application , I need to call the below method in Managed C++ (C++/CLI)
in which i want to pass the above data contact.
ClientSideWrapper.ClientInterface iClient = new ClientSideWrapper.ClientInterface();
iClient.sendMessage(handle,subscriptionData);
I need to create a method in Managed C++ (C++/CLI) , so that i can pass that datacontract (details) from C# to Managed C++ code and do the required processing.
But it seems Managed C++ will not take datacontract as parameter as i am getting the below error:
with this function in Manged C++ .
EXPORT_VOID sendMessage(handle_t binding,DataContracts::NotificationDataContract^ dc);
error C3395: 'sendMessage' : __declspec(dllexport) cannot be applied to a function with the __clrcall calling convention
Please let me know how to handle this scenario.
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
10-Feb-15 0:05am
View
Thank you for your help. Please let me know if there are any general tips for avoiding /resolving issues with dependencies.
Thanks,
Sudhakar
Member 3975629
2-Jan-15 7:06am
View
could you please give me an windows desktop example that uses App.config
Member 3975629
5-Nov-14 8:35am
View
I have an extern variable char UniqueID[88] in another .h file . and i can that access in my file.
I am getting the below errors, though i've include the header file where char UniqueID[88] is declared.
InformManager.obj : error LNK2020: unresolved token (0A0003BF) "char * UniqueID" (?UUID@@3PADA)
InformManager.obj : error LNK2001: unresolved external symbol "char * UniqueID" (?UUID@@3PADA)
Debug\InformManager.dll : fatal error LNK1120: 2 unresolved externals
Member 3975629
5-Nov-14 7:30am
View
I have a extern variable char UniqueID[88] in another file . and i can access in my file.
so do you want me to try something like this
DataContracts::InformDataContract^ InformDataContract=gcnew DataContracts::InformDataContract();
InformDataContract->UniqueID= Marshal::PtrToStringAnsi((IntPtr) (const char *)UniqueID );
if i do so it is giving the below error .. please advise on this.
error C2440: 'type cast' : cannot convert from 'co
nst char *' to 'System::IntPtr'
No user-defined-conversion operator available that can perform this conv
ersion, or the operator cannot be called.
Member 3975629
22-Apr-14 3:02am
View
Thank you
Member 3975629
21-Apr-14 7:35am
View
I am able to display & (ampersand) using &
But I am not sure how to display euro , pound ,cent symbols.
Please let me know any ideas/suggestions on this.
Thanks,
Sudhakar
Member 3975629
24-Mar-14 9:31am
View
Thanks for the link on mutex. but how singleton is different from Mutex. I mean functionality wise singleton also allows only one instance of the class.
Thanks,
Sudhakar
Member 3975629
10-Mar-14 10:50am
View
Thanks a lot to all of you who tried to help me in answering the question.
Solution 4 is working fine. it is addressing my requirements.
Appreciate your help.
Thank you All,
Sudhakar
Member 3975629
10-Mar-14 4:52am
View
Hi Jochen,
Could you please look into the below and let me know if you have any ideas on that ? I would like to dynamically format the hex string into groups of 4 numbers.I mean based on the length of the value variable in the question i need to format instead of hard coding with shift operator many times.
http://www.codeproject.com/Questions/740522/How-to-display-a-hexa-decimal-value-with-a-space-a
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
10-Mar-14 4:23am
View
Thanks for your solution. it seems working on windows fine. but on Linux it is giving the below error with the same above code though i have used unsignd long long as the data type for value .Please let me know if you have any idea/suggetion on this.
error: right shift count >= width of type
And also please let me know how to avoid hard coding of here with shifts. I mean here i used 11 groups of 4 digits by using >> operator. but is there any way that we can dynamically get the format string with different length of value ? and also what could be the max value of a int64 value ? i mean how many max digits can it have ?
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
3-Mar-14 5:36am
View
Ok. thanks. btw can't we give extra size. I mean more than size of buffer.
Member 3975629
3-Mar-14 5:13am
View
char result[255] = {0};
char formatStr[20] = {0};
unsigned char precision;
precision i am passing as 16
Member 3975629
24-Feb-14 10:25am
View
Thank you. my doubts are cleared. appreciate your help.
-Sudhakar
Member 3975629
24-Feb-14 6:10am
View
Thanks a Lot for your explanation.
My input is a sequence of hexadecimal digits ( Eg: 0x1234567890ABCDEF), of arbitrary length, (ofcourse i will remove the 0x part before feeding it to algorithm as you suggested)
My aim is to pass the Final Value (hexadecimal char array)
to a method which takes void* as parameter.
Could you please let me know what this piece of code exactly do ?
and why it is taking half of the length ?
Please refer to the code that i already pasted in the starting of this thread.
Please ignore cout statement.
for(unsigned int i = 0; i < strValue.length()/2; ++i )
{
sscanf( strValueHex + 2 * i, "%2x", &temp );
FinalValue[i] = temp;
}
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
20-Feb-14 8:21am
View
Thank You
Member 3975629
20-Feb-14 8:15am
View
do we need strcasecmp macro here ?? I am just using strtoull.
is it for just example or do we need strcasecmp for strtoull to work ?
Please let me know your suggestions/ideas on this ?
My understanding is I can remove strcasecmp related code in the above macro since i am using strtoull .
Thanks
Member 3975629
20-Feb-14 8:08am
View
Any suggestions/ideas on the above questions are Welcome.
Appreciate your Help.
Thanks.
Sudhakar
Member 3975629
20-Feb-14 6:26am
View
However, you should feed it with, for instance "12", instead of "0x12".
if I feed it as "0x12" will it give wrong results ?? or should I not pass like that ?
why I am asking is my input comes like that "0x1234567890123456" .
Please let me know your suggestions on this.
Thanks.
Member 3975629
20-Feb-14 6:15am
View
How to print the value of every individual byte.?
Member 3975629
20-Feb-14 5:53am
View
Thanks. it is working fine after putting it in top.
Member 3975629
20-Feb-14 4:40am
View
I used the above code .while compiling on visual studio it is giving the below error
error C3861: 'strtoull': identifier not found
I added #include <stdlib.h> also. Please let me know how to fix this error. Appreciate your help.
Thanks,
Sudhakar
Member 3975629
20-Feb-14 3:47am
View
if i type cast the Finalvalue to char* it is printing some symbols ╠↕
i am not sure what are those symbols ? ╠↕
are they equivalnet to "0x12" in hexa ??
Member 3975629
20-Feb-14 3:10am
View
I have a method in my code which takes a void* as parameter.
to pass a hexa decimal value it is using the following code.
I am not able to understand why it was written like that. I tried to print
the value (FinalValue) it is printing just a differnt address (hexa decimal) value every time.
Could you please explain me any suggestion/ideas on this below code ?
Will the below code work for big hexa decimal string like "0xFFFFFFFFFFFFFFFF" without any code change ?? I am not able to understand why it is taking half of the length of original string.
Basically i could not understand it's output/intention.
Appreciate your help
code:
void main()
{
//std::string seedStr = "0xFFFFFFFFFFFFFFFF";
std::string strValue = "0x12";
int strValuelen = 0;
unsigned char* FinalValue= new unsigned char[(strValue.length()/2)+1];
memset(FinalValue,0, (strValue.length()/2)+1);
//convert the strValue to hex
char* strValueHex = (char*)strValue.c_str();
int temp;
for(unsigned int i = 0; i < strValue.length()/2; ++i )
{
sscanf( strValueHex + 2 * i, "%2x", &temp );
FinalValue[i] = temp;
}
std::cout << ((void *)FinalValue);
getch();
}
Member 3975629
18-Feb-14 9:31am
View
when i use miValue = _strtoui64(strValue.c_str() , NULL, 16); it is compiling and working fine on windows. but on gentoo linux it is giving the below error
error: '_strtoui64' was not declared in this scope
any ideas /suggestions appreciated.
Member 3975629
18-Feb-14 6:35am
View
Thank you. It is working as expected after using _strtoui64() method
Member 3975629
18-Feb-14 2:22am
View
I am trying the below code in C++. it is returning some other value but i am expecting
0xFFFFFFFFFFFFFFFF. Is there any mistake here ?
If i give 0x0fff ffff ffff fffb it is working as i expected as below 0xFFF FFFF FFFF FFFB" Please let me know any ideas ? thanks.
std::string str = "0xFFFFFFFFFFFFFFFF";
long long val2 = _strtoi64(str.c_str() , NULL, 16);
it is retuning 0x7ffffffffffffff but i am expecting 0xFFFFFFFFFFFFFFFF
Member 3975629
17-Feb-14 9:10am
View
Thanks a lot. It is working. You saved my day dear friend. I appreciate your timely help.
-Sudhakar
Member 3975629
17-Feb-14 8:14am
View
on Linux it is giving the below error ? any ideas/suggestions appreciated ?
error: format '%llX' expects type 'long long unsigned int', but argument 3 has type 'int'
I did code like this.
int main(){
char result[255] = {0};
char formatStr[20] = {0};
#ifdef _MSC_VER
sprintf(formatStr, "%%0%uI64X", precision);
#else
sprintf(formatStr, "%%0%llX", precision);
#endif
char* output = result;
if (prefix)
{
sprintf(output, "0x");
output += 2;
}
sprintf(output, formatStr, val);
puts(result);
}
Member 3975629
17-Feb-14 5:55am
View
Thanks a lot. Awesome explanation. most of my doubts are cleared.
if you see in my code i am trying to use _snprintf as follows. i've tried to fit the fix given by you as follows. but it seems not working as expected. please let me know if did any mistake here.
if (precision > 0)
_snprintf(precisionMod, sizeof(precisionMod), ".%uI64", precision);
Member 3975629
17-Feb-14 5:05am
View
when i use it in my code as follows it is giving the out put as follows
0x1234567A(null)
with the below code
sprintf(formatStr, "%%#%0uI64X", precision);
sprintf(formatStr,"%%%s%s%s",precisionMod, typeMod);
is there any way that we can pad with zeros on left side of the hexa string
Member 3975629
17-Feb-14 3:44am
View
Thank you very much. it seems working.
I have one question. How can i use the above in my format. I tried as follows in my code . but it seems not working. Please correct me if I am wrong. Appreciate your help.
_snprintf(precisionMod, sizeof(precisionMod), "%#16I64x", precision);
Member 3975629
17-Feb-14 3:06am
View
Yes. i am using VC++ and it supposed to work on Linux as well.
Do I need to do something like this ? I did but it is giving some other symbols.
Please let me know how to use your suggestion in code (it should work on both windows and Linux)
_snprintf(precisionMod, sizeof(precisionMod), ".%'%#I64x'", precision);
Member 3975629
17-Feb-14 2:27am
View
the code is here:
#include <stdio.h> /* printf, NULL */
#include <stdlib.h> /* strtoul */
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<wchar.h>
#include<iostream>
using namespace std;
int main ()
{
//unsigned long long val = 0x1234567890123456;
unsigned int val = 0x1234567A;
char result[255] = {0};
char formatStr[20] = {0};
char typeMod[2] = {0};
unsigned char precision=16;
sprintf(typeMod, "X");
char precisionMod[4] = {0};
if (precision > 0)
_snprintf(precisionMod, sizeof(precisionMod), ".%u", precision);
sprintf(formatStr, "%%%s%s%s", precisionMod, "", typeMod);
char* output = result;
sprintf(output, "0x");
output += 2;
sprintf(output, formatStr, val);
puts(result);
getch();
return 0;
Member 3975629
17-Feb-14 2:26am
View
I am trying to convert an unsigned long long val = 0x1234567890123456; to a string "0x1234567890123456" but i am not aqble to convert it even if i use "%llu" as format specifier with the code provided in code-section
But I am able to convert an unsigned int val = 0x1234567A; to "0x1234567A".
Could you please let me know what i have to do to achieve this ?? Appreciate your help.
I want to convert an unsigned long long val = 0x1234567890123456; to a string "0x1234567890123456" with the below code.
Member 3975629
10-Feb-14 3:45am
View
Thanks. it is working. BTW I am using CEGUI library for edit box stuff/GUI . i am looking into how i can do with CEGUI as you suggested solution.
Thanks a lot. I will contact you if i encounter any further issues. Appreciate your Help.
Thanks,
Sudhakar
Member 3975629
10-Feb-14 3:12am
View
I would like to put it into a string using sscanf as below so that i can display it in an edit box. But it is crashing. could you please let me know how i can put the formatted value in a string and while retrieving it i should be able to get it as a normal hexa decimal number so that i can do calculations with that Hexa number.
Appreciate your help.
Thanks,
Sudhakar
Member 3975629
7-Feb-14 9:25am
View
Thank you very much. I am trying it now. Appreciate your help.
Thanks,
Sudhakar
Show More