Click here to Skip to main content
15,797,960 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Get Supported File System Pin
john563219-Dec-17 0:14
john563219-Dec-17 0:14 
GeneralRe: Get Supported File System Pin
Jochen Arndt19-Dec-17 0:53
professionalJochen Arndt19-Dec-17 0:53 
QuestionSearching string not working Pin
Anonygeeker18-Dec-17 23:10
Anonygeeker18-Dec-17 23:10 
AnswerRe: Searching string not working Pin
Richard MacCutchan18-Dec-17 23:40
mveRichard MacCutchan18-Dec-17 23:40 
GeneralRe: Searching string not working Pin
Jochen Arndt18-Dec-17 23:57
professionalJochen Arndt18-Dec-17 23:57 
GeneralRe: Searching string not working Pin
Richard MacCutchan19-Dec-17 3:42
mveRichard MacCutchan19-Dec-17 3:42 
GeneralRe: Searching string not working Pin
Anonygeeker19-Dec-17 0:10
Anonygeeker19-Dec-17 0:10 
AnswerRe: Searching string not working Pin
CPallini19-Dec-17 0:26
mveCPallini19-Dec-17 0: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 20:13
steffi12317-Dec-17 20:13 
AnswerRe: In MFC how to achieve multilevel undo/redo operations for CRichEditCtrl? Pin
Victor Nijegorodov17-Dec-17 22:03
Victor Nijegorodov17-Dec-17 22:03 
AnswerRe: In MFC how to achieve multilevel undo/redo operations for CRichEditCtrl? Pin
_Flaviu17-Dec-17 23:13
_Flaviu17-Dec-17 23:13 
QuestionHow to insert char* to char array - WITHOUT using string Pin
Vaclav_16-Dec-17 5:52
Vaclav_16-Dec-17 5:52 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
PIEBALDconsult16-Dec-17 5:57
professionalPIEBALDconsult16-Dec-17 5:57 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
Victor Nijegorodov16-Dec-17 6:06
Victor Nijegorodov16-Dec-17 6:06 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
leon de boer16-Dec-17 6:08
leon de boer16-Dec-17 6:08 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Vaclav_16-Dec-17 11:43
Vaclav_16-Dec-17 11:43 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Victor Nijegorodov16-Dec-17 22:31
Victor Nijegorodov16-Dec-17 22:31 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Vaclav_20-Dec-17 8:25
Vaclav_20-Dec-17 8:25 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
jschell16-Dec-17 9:55
jschell16-Dec-17 9:55 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
Richard MacCutchan16-Dec-17 10:51
mveRichard MacCutchan16-Dec-17 10:51 
AnswerRe: How to insert char* to char array - WITHOUT using string Pin
Munchies_Matt20-Dec-17 4:47
Munchies_Matt20-Dec-17 4:47 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Vaclav_20-Dec-17 8:31
Vaclav_20-Dec-17 8:31 
GeneralRe: How to insert char* to char array - WITHOUT using string Pin
Munchies_Matt20-Dec-17 22:53
Munchies_Matt20-Dec-17 22:53 
QuestionHow know if a window is above another Pin
Schehaider_Aymen15-Dec-17 6:46
Schehaider_Aymen15-Dec-17 6:46 
AnswerRe: How know if a window is above another Pin
Rick York15-Dec-17 7:09
mveRick York15-Dec-17 7: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.