Click here to Skip to main content
15,886,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
Try
#include <stdio.h>
#include <string.h>
#define MAX 10

int srch(const char *a[],char *b)
{
  int i = 0;
  while ( a[i] != NULL)
  {
    if ( ! strcmp( b, a[i]) ) return i;
    ++i;
  }
  return -1;
}


int main()
{
  int index; 
  const char *a[]={"abc","xyz","lmn", NULL};
  char b[MAX];
  printf("\nplease, enter string to find\n");

  if ( fgets(b, MAX, stdin) )
  {
    // remove the newline 
    for (index = 0; index < MAX; ++index)
      if ( b[index] == '\n')
      {
        b[index] = '\0';
        break;
      }
    
    printf("string to find '%s'\n",b);
    index = srch( a, b);
    if ( index != -1 )
      printf("string found at index = %d\n", index);
    else
      printf("string not found\n");
  }
  return 0;
}

Please note, fgets includes the newline in the string, that's the reason for the clumsy code used to remove it.
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 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Vaclav_20-Dec-17 7:31
Vaclav_20-Dec-17 7:31 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Munchies_Matt20-Dec-17 21:53
Munchies_Matt20-Dec-17 21:53 
QuestionHow know if a window is above another Pin
Schehaider_Aymen15-Dec-17 5:46
Schehaider_Aymen15-Dec-17 5:46 
AnswerRe: How know if a window is above another Pin
Rick York15-Dec-17 6:09
mveRick York15-Dec-17 6:09 

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.