Click here to Skip to main content
16,016,290 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Code consuming lot of RAM (Memory) Pin
User 1350945019-Dec-17 10:03
professionalUser 1350945019-Dec-17 10:03 
AnswerRe: Code consuming lot of RAM (Memory) Pin
KarstenK20-Dec-17 6:47
mveKarstenK20-Dec-17 6:47 
QuestionGet Supported File System Pin
john563218-Dec-17 22:48
john563218-Dec-17 22:48 
AnswerRe: Get Supported File System Pin
Jochen Arndt18-Dec-17 23:03
professionalJochen Arndt18-Dec-17 23:03 
GeneralRe: Get Supported File System Pin
john563218-Dec-17 23:14
john563218-Dec-17 23:14 
GeneralRe: Get Supported File System Pin
Jochen Arndt18-Dec-17 23:53
professionalJochen Arndt18-Dec-17 23:53 
QuestionSearching string not working Pin
Anonygeeker18-Dec-17 22:10
Anonygeeker18-Dec-17 22:10 
AnswerRe: Searching string not working Pin
Richard MacCutchan18-Dec-17 22:40
mveRichard MacCutchan18-Dec-17 22:40 
Anonygeeker wrote:
But I am getting segmentation fault. Why?
Because your original array does not contain a null terminator. You have:
C++
char *a[]={"abc","xyz","lmn","NULL"};

but "NULL" is a quoted string, not a NULL value, so your loop will continue until it causes the fault.

You also have:
C++
printf("%c\n",a[i]);

but the array is an array of pointers, not characters. You need to use the string identifier in your format string like:
C++
printf("%s\n",a[i]); // use s to print a character aray

And finally (although I may have missed other mistakes) you have:
C++
char *b; // what does this point to?
int l;
printf("\nenter string to find\n");
fgets(b,MAX,stdin); // but b does not point to anything
printf("%c",*b); // again %c means a single character

It should be:
C++
char b[MAX];
int l;
printf("\nenter string to find\n");
fgets(b,MAX,stdin);
printf("%s",b);


I strongly suggest you get a good book on C and learn the basics of single elements, arrays, pointers, printf format strings etc.
GeneralRe: Searching string not working Pin
Jochen Arndt18-Dec-17 22:57
professionalJochen Arndt18-Dec-17 22:57 
GeneralRe: Searching string not working Pin
Richard MacCutchan19-Dec-17 2:42
mveRichard MacCutchan19-Dec-17 2:42 
GeneralRe: Searching string not working Pin
Anonygeeker18-Dec-17 23:10
Anonygeeker18-Dec-17 23:10 
AnswerRe: Searching string not working Pin
CPallini18-Dec-17 23:26
mveCPallini18-Dec-17 23:26 
QuestionIn MFC how to achieve multilevel undo/redo operations for CRichEditCtrl? Pin
steffi12317-Dec-17 19:13
steffi12317-Dec-17 19:13 
AnswerRe: In MFC how to achieve multilevel undo/redo operations for CRichEditCtrl? Pin
Victor Nijegorodov17-Dec-17 21:03
Victor Nijegorodov17-Dec-17 21:03 
AnswerRe: In MFC how to achieve multilevel undo/redo operations for CRichEditCtrl? Pin
_Flaviu17-Dec-17 22:13
_Flaviu17-Dec-17 22:13 
QuestionHow to insert char* to char array - WITHOUT using string Pin
Vaclav_16-Dec-17 4:52
Vaclav_16-Dec-17 4:52 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
PIEBALDconsult16-Dec-17 4:57
mvePIEBALDconsult16-Dec-17 4:57 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
Victor Nijegorodov16-Dec-17 5:06
Victor Nijegorodov16-Dec-17 5:06 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
leon de boer16-Dec-17 5:08
leon de boer16-Dec-17 5:08 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Vaclav_16-Dec-17 10:43
Vaclav_16-Dec-17 10:43 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Victor Nijegorodov16-Dec-17 21:31
Victor Nijegorodov16-Dec-17 21:31 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Vaclav_20-Dec-17 7:25
Vaclav_20-Dec-17 7:25 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
jschell16-Dec-17 8:55
jschell16-Dec-17 8:55 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
Richard MacCutchan16-Dec-17 9:51
mveRichard MacCutchan16-Dec-17 9:51 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
Munchies_Matt20-Dec-17 3:47
Munchies_Matt20-Dec-17 3:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.