Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,

I need to concatenate "@" symbol to a string in C++/CLI as follows.

Ex:

C++
String^ str1 = "OXF";
 String^ str2 = "@"+ str1;


But i am getting compile errors saying as follows: Could you please let me know how to resolve them.


VB
NotificationManager.cpp(127) : error C2018: unknown character '0x40'
NotificationManager.cpp(127) : error C2065: '"': undeclared identifier
NotificationManager.cpp(127) : error C2146: syntax error : missing ';' before identifier '"'
NotificationManager.cpp(127) : error C2065: '"'  : undeclared identifier



Thanks,
Sudhakar
Posted
Comments
Richard MacCutchan 14-Aug-15 2:19am    
You most probably have something missing before these lines of code. Take a closer look at what you have written.
Member 3975629 14-Aug-15 2:22am    
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
Richard MacCutchan 14-Aug-15 2:27am    
I just tried it and it works fine. It must be something different in your source module, or project settings.
Member 3975629 14-Aug-15 3:02am    
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:26am    
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.

1 solution

Like Richard, I tried your code, namely
C++
#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
    String^ str1 = "OXF";
    String^ str2 = "@" + str1;
    Console::WriteLine(str2);

    return 0;
}

compiles and runs fine on my PC.

Possibly there is something wrong in your compilation environment.
 
Share this answer
 
Comments
Member 3975629 14-Aug-15 3:02am    
I tried as below and it worked with single quote. instead of double quotes in my dev environment.
String^ str1 = "OXF";
String^ str2 = '@'+ str1;
CPallini 14-Aug-15 3:06am    
That's pretty strange in my opinion. Could be you had a stray character in your original code?
Member 3975629 14-Aug-15 3:25am    
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.
CPallini 14-Aug-15 3:41am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900