473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Find/Replace with char arrays without string functions

Heya everyone,

I'm trying to write a program that finds and replace an array of
characters defined by the user in a text file. Basicly the program
finds and replaces a substring typed in by the user. I've got the
opening file and displaying its contents down, but the problem is, I
can not use any of the string member functions to find and replace. I
am trying to read a line of text from the input file at a time and
comparing it to what the user typed in. All I got so far is the
following code segment that only finds a character:

ifstream inFile;
const int i = 11;
char find[i];
const int j = 81;
char input[j];
char ch;
int count = 0;

inFile.getline(input,j);
inFile.get(ch);
while(!inFile.eof())
{

while(ch != '\n')
{
if(find[i-11] == ch)
count++;
inFile.get(ch);

}
inFile.getline(input,j);
}

Any help would be greatly appreciated!!

Thank you
Dmitridj

Nov 4 '06 #1
0 1608

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
by: Tim Johansson | last post by:
I'm new to C++, and tried to start making a script that will shuffle an array. Can someone please tell me what's wrong? #include <iostream.h> #include <string.h> int main () {...
2
by: Peter Nilsson | last post by:
In a post regarding toupper(), Richard Heathfield once asked me to think about what the conversion of a char to unsigned char would mean, and whether it was sensible to actually do so. And pete has...
28
by: Merrill & Michele | last post by:
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(void){ char *p; p=malloc(4); strcpy(p, "tja"); printf("%s\n", p); free(p); return 0;
19
by: Paul | last post by:
hi, there, for example, char *mystr="##this is##a examp#le"; I want to replace all the "##" in mystr with "****". How can I do this? I checked all the string functions in C, but did not...
58
by: LuisC | last post by:
What is better for holding small numbers in a program? I know that char uses less memory, but, with 32 or 64 bits systems, there are advantages (such as processing time) in using int instead of...
4
by: ICPooreMan | last post by:
I've got some code which works in firefox that's giving me fits in IE7 (maybe other versions too I haven't tested it). What I want to do is get the oncontextmenu attribute of something, change the...
18
by: Umesh | last post by:
Do you have any answer to it? thx.
33
by: Michael B Allen | last post by:
Hello, Early on I decided that all text (what most people call "strings" ) in my code would be unsigned char *. The reasoning is that the elements of these arrays are decidedly not signed. In...
12
by: implement | last post by:
Hi all! I try to code my own version of replace but it doesn't work. I hope somebody can help me out. It only replaces the first char!. Why I don't use the public string.replace function?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.