Finding word in a two dimensional array

  • Thread starter Thread starter rambo3131
  • Start date Start date
  • Tags Tags
    Array
Click For Summary
SUMMARY

The discussion centers on searching for a word in a two-dimensional array using the C programming language. It is established that pointers are not necessary for this task; instead, array indexes can be utilized within two nested for loops. The string comparison function strcmp is recommended for comparing strings, as direct comparison using str == "abc" is incorrect.

PREREQUISITES
  • Understanding of C programming language syntax
  • Familiarity with two-dimensional arrays in C
  • Knowledge of string manipulation functions in C, specifically strcmp
  • Basic control structures in C, including loops
NEXT STEPS
  • Study the implementation of nested loops in C for array traversal
  • Learn about string handling in C, focusing on functions like strcmp and strcpy
  • Explore memory management in C, particularly the use of pointers
  • Investigate alternative data structures for string storage and searching, such as linked lists
USEFUL FOR

C programmers, computer science students, and software developers interested in efficient string searching techniques within arrays.

rambo3131
Messages
18
Reaction score
0
Hi, I have a question about C.In a two dimensional array ,I will search a word (not a letter).Do i have to use pointers?
 
Technology news on Phys.org
rambo3131 said:
Hi, I have a question about C.In a two dimensional array ,I will search a word (not a letter).Do i have to use pointers?
No, you can use array indexes in two nested for loops. Note that you will need to use a string comparison function (strcmp) rather than a condition like this one:
if(str == "abc")
 

Similar threads

Replies
7
Views
4K
  • · Replies 32 ·
2
Replies
32
Views
3K
  • · Replies 6 ·
Replies
6
Views
1K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
6
Views
3K
  • · Replies 23 ·
Replies
23
Views
2K
  • · Replies 25 ·
Replies
25
Views
3K