| | |
New User
![]() |
•
•
Join Date: Nov 2004
Posts: 108
Reputation:
Solved Threads: 3
Welcome to the forums.
1. When you have a problem(s). Ask a question releating to that problem.
2. Post any realated code with the problem.
3. Wait until someone like me, who is a genius, to help you with your problem
.
Enjoy your stay at the Daniweb C And C++ forums and make sure you keep your arms and legs inside while you are here
1. When you have a problem(s). Ask a question releating to that problem.
2. Post any realated code with the problem.
3. Wait until someone like me, who is a genius, to help you with your problem
.Enjoy your stay at the Daniweb C And C++ forums and make sure you keep your arms and legs inside while you are here
Join me on IRC:
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
Server: irc.daniweb.com
Channel: #C++
Chat Via:
http://daniweb.com/chat/minichat.php
or
Your favorite IRC client.
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by prog-bman
Welcome to the forums.
1. When you have a problem(s). Ask a question releating to that problem.
2. Post any realated code with the problem.
3. Wait until someone like me, who is a genius, to help you with your problem.
Enjoy your stay at the Daniweb C And C++ forums and make sure you keep your arms and legs inside while you are here
I would be a lot recognizing if you help me for this problem:
I have a text file and I would be searching on this file some word of this type "wordi" where i is a natural number. Since these words come written on this file second of a sure number j (that indicate the number of the inputs) es. j=2 in the file I'll find word1 and word2, I have tried to do a for cicle but I don't succeed to do a concatenation of the string (word) and the number (j).
Can you help me?
Thank you
PS. Excuse me for the english!!!!
•
•
Join Date: Jul 2005
Posts: 1,671
Reputation:
Solved Threads: 261
Within the file you are using all data is binary. When the file data is read into your program, your program converts that data into whatever it's been told to convert it into based on what variable is going to hold the information in the program. To concatenate to variables you can use a variety of techniques based on what the variable types are. If the variable types are both null terminated strings you can use strcat() to combine them into a single string. If the variables are both instances of the STL string class you can use the + operator to concatenate them. If one variable is a null terminated string and the other is a numerical variable you can use ssprintf() to concatenate them. If one variable is an instance of the STL string class and the other is a numerical variable you can use an istringstream to concatenate them. And so on.
•
•
Join Date: Oct 2005
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Lerner
Within the file you are using all data is binary. When the file data is read into your program, your program converts that data into whatever it's been told to convert it into based on what variable is going to hold the information in the program. To concatenate to variables you can use a variety of techniques based on what the variable types are. If the variable types are both null terminated strings you can use strcat() to combine them into a single string. If the variables are both instances of the STL string class you can use the + operator to concatenate them. If one variable is a null terminated string and the other is a numerical variable you can use ssprintf() to concatenate them. If one variable is an instance of the STL string class and the other is a numerical variable you can use an istringstream to concatenate them. And so on.
Now I have another problem. I have a function that search a string in a text file. This function return an int: 0 if the string I must be search isn't in the file, 1 otherwise.
The problem is: if the searching string is "input1" and in the file there is a string "counter_input1" the function return 1 instead must be return 0.
Bye
![]() |
Similar Threads
- Internet explorer user problems (Web Browsers)
- XP Pro new user account causes pc to reboot at logon (Windows NT / 2000 / XP)
- User clicked no on a java applet from IBM (Java)
- Novell 6 128Bit 25 User Licenses (Novell)
Other Threads in the C Forum
- Previous Thread: Pattern Searching
- Next Thread: Help Needed in C. Urgent
| Thread Tools | Search this Thread |
* adobe ansi api array asterisks binarysearch calculate centimeter char character cm convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory feet fflush fgets file floatingpointvalidation fork frequency function getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches infiniteloop interest intmain() kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match meter microsoft mqqueue mysql number oddnumber odf open opendocumentformat openwebfoundation owf pattern pdf performance posix power probleminc program programming pyramidusingturboccodes read recv recvblocked repetition scanf scheduling segmentationfault send single socketprograming socketprogramming stack standard strchr string suggestions systemcall unix urboc user variable voidmain() wab whythiscodecausesegmentationfault win32api windows.h






