944,008 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2245
  • C RSS
Oct 25th, 2005
0

New User

Expand Post »
Hello! I'm a new user of this forum. I'm italian and I work like programmer. I need of some information about C code and I wish you help me!
Bye bye
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ricciola is offline Offline
6 posts
since Oct 2005
Oct 25th, 2005
0

Re: New User

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
Reputation Points: 14
Solved Threads: 4
Junior Poster
prog-bman is offline Offline
108 posts
since Nov 2004
Oct 26th, 2005
0

Concatenation of a string with a number

Quote 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
Thanks!!!!
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!!!!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ricciola is offline Offline
6 posts
since Oct 2005
Oct 26th, 2005
0

Re: New User

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.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Nov 3rd, 2005
0

Search string in a text file

Quote 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.
Thank you, I have resolved this problem using the sprintf function!!!
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ricciola is offline Offline
6 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Pattern Searching
Next Thread in C Forum Timeline: Help Needed in C. Urgent





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC