473,387 Members | 1,578 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,387 software developers and data experts.

STRCAT problem

Hi!
I wanted to thank you a lot for the help given yesterday...
It`s so great to have people so well prepared trying to help you!

I have another problem: the bold line :
strcat want a pointer as argument, but probably i'm mistaking it ... can anybody help me?


#include <stdio.h>
#include <string.h>

main ()
{
int i;
char j;
char *ip;

for (i = 0; i < 10; i++)
{
ip=&j;
for (j = 0; j<3; j++)
{
FILE *fp;

char filename[17] ;

if (i == 0)
{
strcpy(filename, "injection-0");
if (j==0) strcat(filename,"_11.txt");
else if (j==1) strcat (filename,*ip);
else if (j==2) strcat (filename,"_12.txt");
}
if ((fp = fopen(filename, "w")) != NULL)
{
fprintf(fp, "mass_part mass_flow_part diam_part accretion surf_ID cel_ID temp vel_abs vel_nor vx vy vz Ax Ay Az Angle Wa Wb Wc WEAR\n");
fclose(fp);
}
}
}
}
Jul 4 '07 #1
1 1787
Silent1Mezzo
208 100+
Hi!
I wanted to thank you a lot for the help given yesterday...
It`s so great to have people so well prepared trying to help you!

I have another problem: the bold line :
strcat want a pointer as argument, but probably i'm mistaking it ... can anybody help me?


#include <stdio.h>
#include <string.h>

main ()
{
int i;
char j;
char *ip;

for (i = 0; i < 10; i++)
{
ip=&j;
for (j = 0; j<3; j++)
{
FILE *fp;

char filename[17] ;

if (i == 0)
{
strcpy(filename, "injection-0");
if (j==0) strcat(filename,"_11.txt");
else if (j==1) strcat (filename,*ip);
else if (j==2) strcat (filename,"_12.txt");
}
if ((fp = fopen(filename, "w")) != NULL)
{
fprintf(fp, "mass_part mass_flow_part diam_part accretion surf_ID cel_ID temp vel_abs vel_nor vx vy vz Ax Ay Az Angle Wa Wb Wc WEAR\n");
fclose(fp);
}
}
}
}
Expand|Select|Wrap|Line Numbers
  1. else if (j==1) strcat (filename,ip);
I don't believe you have to dereference the pointer.
Jul 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Patrick Coleman | last post by:
Hi, I have the following code: char request = "GET "; strcat(request, path); //Path is the path section of a url ie. "/path/test.htm" strcat(request, " HTTP/1.1"); cout<<request<<"\n";...
6
by: Jon | last post by:
using Borland Compiler. x = "this is a string" strcat(x,x) strcat(x,x) will produce "this is a stringthis is a stringthis is a stringthis is a stringt"
5
by: Ian Stanley | last post by:
Hi, Having not done any C programming for a while I am trying to get back into it by converting an old java assignment into C. The problem is I am getting a segmentation fault at runtime which I...
18
by: Ian Stanley | last post by:
Hi, Continuing my strcat segmentation fault posting- I have a problem which occurs when appending two sting literals using strcat. I have tried to fix it by writing my own function that does the...
23
by: JC | last post by:
hi, i want to combine two string together.. and put in to another string. how can i do . i try myself.. with the follow code. but seem can't get the result i want.. i want to get the result with...
87
by: Robert Seacord | last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed Strings" and released a "proof-of-concept" implementation of the managed string library. The specification, source code for...
4
by: nick048 | last post by:
Hi, I have this problem: int n; char nToChar; char firstString = "The number is: "; char resp; /* HERE MAIN WITH THE INPUT OF n*/
3
by: sail0r | last post by:
Perhaps this is obvious but I am not sure what is going on... Here is the relevant code: char *command; char *argument; char url="file:///usr/u/myname/Project/cats/"; char...
28
by: Mahesh | last post by:
Hi, I am looking for efficient string cancatination c code. I did it using ptr but my code i think is not efficient. Please help. Thanks a lot
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.