dev c++ - Problems assigning char string to char array -


I have already read all the pre-related answers to my problem, however, I am unable to understand it is not a very bright codec I can check my problem.

I am trying to write a CSV file using entries from the 2D array. String.h has already been included in the main ().

  zero create_marks_csv (int root [] [20], float p [] [20], float si [] [20], int n) {system ("cls"); Four straws [100], strobe [100], Strauss [100]; Printf ("Enter the filename for \ nwriting matrix" :); Gets (str1); Printf ("create \ n% s.csv file", str1); File * FP; Int i, j; Str1 = strcat (str1, "csv."); Str1 = strcat ("C: \\ User \\ Neil \\ Document \\ Trust CSV Log \\", str1); fp = fopen (str1, "w +"); For (i = 1; i & lt; = n; i ++) {for (j = 1; j & lt; = n; j ++) {if (i == j) fprintf (FP, "X "); Other fprintf (FP, "% d", root [i] [j]); } Fprintf (FP, "\ n"); } Fclose (fpose); Printf ("File created:% s", str1); System ("cls"); }   

Alerts and Errors are as follows:

  5 20c: \ user \ neil \ document \ main.c [warning] #include additional tokens End of Instructions [enabled by default] C: \ Users \ Neil \ Documents \ main.c in function 'create_marks_csv': 168 6 C: \ Users \ Neil \ Documents \ main.c [Error] Type incompatible type 'four' Type [4] Type 'four' * 1696C: \ user \ neil \ document \ main.c [error] Incompatible type when 'char [100]' type 'four * '28C: \ Users \ Neil \ Documents \ Make Makefile Target win recipe 'main.o' failed    

Each time you type str1 = , then you are asking to change the compiler to str1 so that it indicates that the location in the memory is found on its right hand side = Sign in but you have declared four straw [100] , which means that str1 is interpreted as an indicator, that place To start the 100-letter block It can only tell if the declaration is allocated to them, then there is no point in writing str1 = . The first argument of

strcat is likely to be a disaster, although passing the string continuously, although the compiler does not feel like the first argument of vortex is concatenation There should be sufficiently a character buffer to catch the results of To add something to the end of a constant string, you can allocate a buffer adequately, then make a constant copy of the string, then call strcat .

In general, what you probably need to do without the return value of strcat is that strcat is defined as There is no need to write = on the right side . It is advisable to use

instead of fgets , because then you can avoid the possibility that you can get more input If you assign 100 characters to your biggest buffer to fit into your allotted character buffer, then you only get the string "C: \\ Users \\ Neil \\ Document \\ Trust CSV log \\" . (Other 5 characters are required to keep the string ".csv" and the terminal faucet character.)

I also noticed that you have str2 Declare and str3 but I did not know why you used one of these. It seems that you do not need both of them, but it may be appropriate to use str2 as a buffer for the last closing of your code.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -